XML to JSON with Attribute

k_prathip
Participant III

I am trying to use XML to JSON policy for the below XML node.

<name attrib="attrib1">12345</name>

Gets transformed to below JSON

"name":{ "attrib":"attrib1", "":"12345" }

I wanted to extract the value 12345, since it is coming with a empty key I am not able to access it.

Solved Solved
0 2 523
1 ACCEPTED SOLUTION

Hi Prathip

You can use the TextNodeName option.

<XMLToJSON name='X2J-1'>
  <Source>request</Source>
  <OutputVariable>whatever</OutputVariable>
  <Options>
      <TextNodeName>TEXT</TextNodeName>
  </Options>
</XMLToJSON>

There are other options, too. Check the documentation.

View solution in original post

2 REPLIES 2

Hi Prathip

You can use the TextNodeName option.

<XMLToJSON name='X2J-1'>
  <Source>request</Source>
  <OutputVariable>whatever</OutputVariable>
  <Options>
      <TextNodeName>TEXT</TextNodeName>
  </Options>
</XMLToJSON>

There are other options, too. Check the documentation.

Thanks it works...