How to extract ![CDATA] from XML response?

Hello all, I have a source that returns xml data with some key attributes contained within ![CDATA] attributes. For example

                <FIRSTNAME>
                    <![CDATA[Thomas]]>
                </FIRSTNAME>

XPath testing has not turned up any way to extract the CDATA information from the xml and we are at a loss as to how to proceed. Has anyone dealt with this before and come up with a viable solution?

Thanks

Hi @joe_gaileyiii,

CDATA is using with the code, to convert some characters that xml interprets as tag. In your case you have a string that contais CDATA.

SO, if you want the value, you nueed to clean that string before.

Hey Joe,

CDATA means Character Data and represents the block of data that could be interpreted as XML, but SHOULD NOT be.

So you should simply be able to read the data like as you would any normal string data from XML.

For example, take this XML:

<app>
  <name>
    <FIRSTNAME>
      <![CDATA[Thomas]]>
    </FIRSTNAME>
    <LASTNAME>Wayne
    </LASTNAME>
  </name>
</app>

XPath Query: app/name/FIRSTNAME would return and just Thomas.
XPath Query: app/name/LASTNAME would return and just Wayne.


1 Like

We do have xml integrations so not a totally new concept. I tried replicating your test (I believe we used the same tool), but it doesn’t work for me I’m not sure how you got that result.

DTD keywords(which includes CDATA) should always be in uppercase.

That change was simply made for the tool, as it caused errors to have uppercase elements for some reason. The result is same for us no matter the case.

Hey Joe,

I am lost here as well. I am not able to reproduce your scenario in the XPath test tool.

Is it possible you could paste/upload the XML you are using in the tool and I would try with the same.

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.