Altova Mailing List Archives>Archive Index >microsoft.public.xsl Archive Home >Recent entries >Thread Prev - XML inside CDATA [Thread Next] Re: XML inside CDATATo: 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/ | ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
