Re: how to get XML document object

Martin Honnen <[email protected]>
Newsgroups gmane.comp.mozilla.devel.xml
Organization Liberty Development
Message-ID <[email protected]>

Tezza wrote:

> I have a string in a JS variable which happens to be a serialised XML
> document from a HTTP request.
> 
> How to I get a DOM XML object which represents this string?

Have you used XMLHttpRequest and got that string from the responseText 
property? Then you could simply use the responseXML property instead 
which XMLHttpRequest automatically creates and populates by parsing the 
response as XML if it is sent with a known XML Content-Type (e.g. 
application/xml, text/xml, application/xhtml+xml, in Firefox 1.5 
image/svg+xml probably too).
Besides that there is DOMParser in Mozilla e.g.
   var xmlDocument = new DOMParser().parseFromString(xmlMarkupAsString, 
'application/xml');



-- 

	Martin Honnen
	http://JavaScript.FAQTs.com/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.