Subject:Parsing XMLFormatted as String within XML Author:Bob Sunbury Date:19 Sep 2005 08:38 PM Originally Posted: 19 Sep 2005 08:36 PM
I am trying to figure out an efficient way to parse xml formatted as test string data being returned from a web service using xslt. I am trying to avoid using a template with complex string manipulation to parse the fields from the text/xml string. I have enclosed a sample response with the elements CITY, STATE and ZIPCODE contained within "data" tags all of which is enclosed within "Result" tags. Here is a sample of the xml that I am trying to parse in my xsl:
<Response>
<Result><?xml version="1.0" encoding="UTF-8"?><data><CITY>NOWHERE</CITY><STATE>PA</STATE><ZIPCODE>15555</ZIPCODE></data></Result><br>
</Response>
Any suggestions are greatly appreciated.
Subject:Parsing XMLFormatted as String within XML Author:Ivan Pedruzzi Date:19 Sep 2005 10:41 PM
Bob,
This is a very bad example in how sometimes web service authors use XML. It usually happens when a web service returns XML as it was a string as consequence the XML get escaped.
In this case what is inside the Result element is just text and requires painful text manipualtion in XSLT.
Subject:Parsing XMLFormatted as String within XML Author:Bob Sunbury Date:05 Oct 2005 09:50 AM Originally Posted: 05 Oct 2005 09:49 AM
Thanks for the info Ivan and your quick response! We found a way to do this within a single style sheet by using two JavaScript functions. The first converts the escaped xml to a valid XML Document Object and the second parses the nodes from the elements within the results of the first function.