Skip to Content
0
Former Member
Apr 29, 2013 at 02:42 PM

Read XML tags dynamically

185 Views

Hi

I have to read the XML dynamically , please see the input and expected output

Input:

String inputPayload = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"

+ "<records xsi:type=\"Opportunity\">"

+ "<Id>ABCD</Id>"

+ "<Amount>1000.0</Amount>" + "</records>";

Output

"<?xml version=\"1.0\" encoding=\"UTF-8\"?>"

< data>

<Object name> Opportunity </Object name>

<records>

<FiledName>ID</FiledName>

<FiledValue>ABCD</FiledValue>

<records>

<records>

<FiledName>Amount</FiledName>

<FiledValue>1000.0</FiledValue>

<records>

< /data>

Please note that the tags Opportunity, ID,Amount etc are dynamic.

Can you please tell how to read this using DOM/SAX or any other method?