Hi team,
I have an XML input.
<?XML><Field1>value</Field1>
<Field2>value<?XML>field names and values</XML>
</Field2>
</XML>
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>_____</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 <Data> 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 <Data>....</Data> 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.