XML to json conversion

Hi team,

I have an XML input.

<?XML>value value<?XML>field names and values So that is XML inside XML. When I use XML to json conversion policy, it only converts the main XML. The sub XML comes out in XML form in json value in key- value format. { Field1: value Field2 : <?XML>_____ } How should I deal with this.

From an XML perspective, what you are showing is not well formed XML. What is the source of your data? Is it documented in any way?

<?xml version="1.0"?>
<IBRequest>
  <MessageName>xyz</MessageName>
  <MessageType>Async</MessageType>
  <MessageVersion>VERSION_1</MessageVersion>
  <From>
    <RequestingNode>nodename</RequestingNode>
    <Password />
  </From>
  <To>
    <FinalDestination>dest1</FinalDestination>
  </To>
  <ContentSections>
    <ContentSection>
      <NonRepudiation />
      <Data><![CDATA[<?xml version="1.0"?><BUILD><FieldTypes> .. ]]></Data>
    </ContentSection>
  </ContentSections>
</IBRequest>

This is the sample content format..hope this is fine to understand.

This XML is dramatically different from the first post … this XML appears well formed. As I look at the field .. I see that it contains “CDATA” … is this the area you are looking at? The idea behind XML CDATA (Character Data) is that the content of the field … can contain anything … including characters that would not normally be allowed in XML. I would imagine that a parser of XML to JSON would create a “String” JSON field that contains the content as-is. If that string is itself XML, then it would be up to your own application logic to apply an XML to JSON processor explicitly against that field.

1 Like