f



converting a document node and children into xml text

is there a way in javascript to convert a DOM node (and it's children)
into an XML text.

i'd like to save the text file somewhere and then later parse it
to re-create the tree.

thx.
0
jman
3/6/2009 12:13:40 PM
comp.lang.javascript 38370 articles. 2 followers. javascript4 (1315) is leader. Post Follow

2 Replies
479 Views

Similar Articles

[PageSpeed] 10

jman, google grouper, wrote:
> is there a way in javascript to convert a DOM node (and it's children)
> into an XML text.

Yes.

Traverse the DOM node subtree and output XML accordingly.

> i'd like to save the text file somewhere and then later parse it
> to re-create the tree.

Why?



0
rf
3/6/2009 12:25:08 PM
jman wrote:
> is there a way in javascript to convert a DOM node (and it's children)
> into an XML text.

It depends on the DOM implementation, with Mozilla's DOM implementation 
you have XMLSerializer e.g.
   var xmlMarkup = new XMLSerializer().serializeToString(domNode);
Opera and Safari support that too I think, Opera also supports the W3C 
DOM Level 3 API for doing that I think.
With IE you use the MSXML DOM implementation, there nodes have a 
property named xml so you can use
   var xmlMarkup = domNode.xml;


-- 

	Martin Honnen
	http://JavaScript.FAQTs.com/
0
Martin
3/6/2009 1:13:00 PM
Reply: