XML Editor
Sign up for a WebBoard account Sign Up Keyword Search Search More Options... Options
Chat Rooms Chat Help Help News News Log in to WebBoard Log in Not Logged in
Show tree view Topic
Go to previous topicPrev TopicGo to next topicNext Topic
Postnext
Bob SunburySubject: 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>&lt;?xml version="1.0" encoding="UTF-8"?&gt;&lt;data&gt;&lt;CITY&gt;NOWHERE&lt;/CITY&gt;&lt;STATE&gt;PA&lt;/STATE&gt;&lt;ZIPCODE&gt;15555&lt;/ZIPCODE&gt;&lt;/data&gt;</Result><br> </Response> Any suggestions are greatly appreciated.

Postnext
Ivan PedruzziSubject: 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.


Ivan Pedruzzi
Stylus Studio Team

Postnext
Ivan PedruzziSubject: Parsing XMLFormatted as String within XML
Author: Ivan Pedruzzi
Date: 20 Sep 2005 09:46 AM

If you are willing to use extension function, some processor support dynamic parsing, see Saxon evaluate for instance
http://www.saxonica.com/documentation/extensions/functions.html



Ivan Pedruzzi
Stylus Studio Team

Postnext
Bob SunburySubject: 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.

Posttop
David ChanSubject: Parsing XMLFormatted as String within XML
Author: David Chan
Date: 18 Jan 2006 12:16 PM
Hi Bob,

Can you direct me for those javascript?
I have the same problem as you in before

Regards
Dave

 
Go to previous topicPrev TopicGo to next topicNext Topic
Download A Free Trial of Stylus Studio 6 XML Professional Edition Today! Powered by Stylus Studio, the world's leading XML IDE for XML, XSLT, XQuery, XML Schema, DTD, XPath, WSDL, XHTML, SQL/XML, and XML Mapping!  
go

Log In Options

Site Map | Privacy Policy | Terms of Use | Trademarks
Stylus Scoop XML Newsletter:
W3C Member
Stylus Studio® and DataDirect XQuery ™are from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2016 All Rights Reserved.