PDA

View Full Version : XML DOM serializer



rtoepfer
7 Nov 2006, 8:00 AM
Anyone have a suggestion for a library to use that takes an XML DOM tree and serializes it to text? I would like to view the underlying structure of the data model in the grid after updates by simple alert statements.

tryanDLS
7 Nov 2006, 8:32 AM
Take a look at this thread

http://jackslocum.com/forum/viewtopic.php?t=453

rtoepfer
8 Nov 2006, 10:04 AM
The other thread deals with the returned object from YUI Connection after a successful XML HTTP Request. Whereas, I am dealing with object returned from YUI-ext grid:

var xml = dataModel.getDocument();

This xml object does not have a responseXML property (I snooped in Firebug). I assume to get a full string representation of the xml document one must use a library that checks all of the properties and reconstructs the string. For me, my xml document is structured in a way that I can use:

var strValues = xml.firstChild.textContent

This method only returns each node's values with new line characters delimiting each value.

rtoepfer
8 Nov 2006, 10:24 AM
This works

var myXMLDoc = dataModel.getDocument();

if( ie )
{
var xmlDocument = new ActiveXObject('Microsoft.XMLDOM');
var markup = myXMLDoc.xml;
}
else
{
var xmlSerializer = new XMLSerializer();
var markup = xmlSerializer.serializeToString(myXMLDoc);
}

alert( markup );