Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: XML inside CDATA

From: Martin Honnen <mahotrash@-----.-->
To: NULL
Date: 6/4/2004 3:43:00 PM

Brian Peddle wrote:

> I have been given an XML document in which there is text I need to extract
> from the an element which has CDATA.  I'd like to just use XSL to handle it
> but after spending a full day on a variety of approaches I am wondering if
> it is even possible with strictly XSLT.  I thought maybe if there was a way
> to assign the element to a variable and some how say that is another XML
> document and then pull what I need.
> 
> Open to suggestions.  Thanks
> 
> <ELEMENT>
>  <![CDATA[
> <Parent>
> <child_1>Something</child_1>
> <child_2 id = "1">foo1</child_2>
> <child_2 id="2">foo2</child_2>
> <child_3>foo3</child_3>
> </Parent>
> ]]>
> </ELEMENT>
> 
> This is the way the XML is sent and I have no control over it's format so
> changing it won't be a solution.

Using DOM scripting (or programming) you can load the XML from file, 
then extract the content of the CDATA node as text and use loadXML to 
parse that text as XML, here is a JScript example:

var xmlDocument = new ActiveXObject('Msxml2.DOMDocument.4.0');
xmlDocument.async = false;
var loaded = xmlDocument.load('test20040604.xml');
var xmlSource = xmlDocument.documentElement.firstChild.nodeValue;
loaded = xmlDocument.loadXML(xmlSource);
alert(xmlDocument.xml)
-- 

	Martin Honnen
	http://JavaScript.FAQTs.com/



transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent