Full version: jsB@nk » Snippet » getXML
URL: https://www.javascriptbank.com/getxml.html
Obtain the contents of an XML element and convert it to text. This script is great for using with Ajax-type applications, when it's neccessary to send back the contents of an element to the server without knowing what's there.
Full version: jsB@nk » Snippet » getXML
URL: https://www.javascriptbank.com/getxml.html
<script>// Created by: Neal Venditto :: http://neal.venditto.org/function getXML(aNode) { var out = ''; if(aNode.nodeType == Node.ELEMENT_NODE) { out = '<'+aNode.nodeName; if(aNode.hasAttributes()) { var atts = aNode.attributes; for(var x=0;x<atts.length;x++) { out +=' '+atts[x].nodeName+'="'+atts[x].nodeValue+'"'; } } if(aNode.hasChildNodes()) { out += '>'; var kids = aNode.childNodes; for(var x=0;x<kids.length;x++) { switch(kids[x].nodeType) { case Node.ELEMENT_NODE: out += getXML(kids[x]); break; case Node.TEXT_NODE: out += kids[x].nodeValue; break; case Node.COMMENT_NODE: out += '<!--'+kids[x].nodeValue+'-->'; break; case Node.CDATA_SECTION_NODE: out += '<'+'![CDATA['+kids[x].nodeValue+']'+']>'; break; } } out += '</'+aNode.nodeName+'>'; } else { out += '/>'; } } return out;}</script><!-- This script downloaded from www.JavaScriptBank.com Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->