Hybrid View
-
3 May 2008 2:32 PM #1
Convert DOM XML Document to string
Convert DOM XML Document to string
Hi everyone!
I've using the next function in order to convert a javascript XML object to string
Is there an easier way to perform the above function using ExtJS?Code:function XMLtoString(elem){ var serialized; try { // XMLSerializer exists in current Mozilla browsers serializer = new XMLSerializer(); serialized = serializer.serializeToString(elem); } catch (e) { // Internet Explorer has a different approach to serializing XML serialized = elem.xml; } return serialized; }
And, also, when making an Ext.Ajax.request the params need to be string? Or can I pass directly a XML DOM object?
Greetings!
-
3 May 2008 6:01 PM #2
1) No, there isn't currently anything that does this.
2) They can either be a string or a JS object.
-
3 May 2008 10:59 PM #3
You shoujld just be able to specify a document as the data using the xmlData option of http://extjs.com/deploy/dev/docs/?cl...member=request
the XHR will convert it:
http://www.w3.org/TR/XMLHttpRequest/#entity-bodySearch the forum: http://www.google.com/coop/cse?cx=01...%3Az7of1ufqccu
Read the docs too: http://extjs.com/deploy/dev/docs/
Scope: http://extjs.com/forum/showthread.ph...642#post257642
-
7 Aug 2009 6:03 AM #4
Thanks!
Thanks!
Thank you for source code phreakermex :-). I'm using EXT GWT actually, but for XSLT transformation on Client I need JavaScript. In which I'm less then newbie.
I could not handle JavaScriptObject in Java, but String is hunky-dory.
Thanks!
-
24 Dec 2010 2:52 AM #5
In Javascript for Selenium IDE reading XML from DOM to XMLString
In Javascript for Selenium IDE reading XML from DOM to XMLString
...when you are reading/displaying a xml file in a browser:
function loadXMLFromDOM2XMLString( xmlString, xmltag, currentChildNode ) {
var nodes = currentChildNode.childNodes;
var i = 0 ;
var node = nodes[i];
while ( i < nodes.length) {
if (node.data == null) {xmltag = '<'+node.localName+'>';} else {xmltag = node.data;};
xmlString = xmlString + xmltag;
xmlString = loadXMLFromDOM2XMLString( xmlString, xmltag, node );
if (node.data == null) {xmltag = '<'+'/'+node.localName+'>';} else {xmltag = "";};
xmlString = xmlString + xmltag;
i++;
node = nodes[i];
}
return xmlString ;
} ;
var xmlString = "";
var xmltag = "";
var currentChildNode = window.document;
xmlString = loadXMLFromDOM2XMLString( xmlString, xmltag, currentChildNode );
xmlString;


Reply With Quote