Search This Blog

Thursday, November 4, 2010

Parsing & using XML in AJAX method by XML DOM Parser

Agenda:

How to parse and use XML data using XML DOM parser using AJAX in your enterprise application.

XML :

AJAX Code snippet (which will be inside the onreadystatechange block):

var xmlDoc;
if (window.DOMParser) { //for Firefox
parser=new DOMParser();
xmlDoc=parser.parseFromString(xmlHttp.responseXML,"text/xml");
} else { //for IE 6+
xmlDoc = xmlHttp.responseXML;
}

var tagValue = xmlDoc.getElementsByTagName("[XML-TAG-NAME]")[(POSITION)];
var attrValue = xmlDoc.getElementsByTagName("[XML-TAG-NAME]")[(POSITION)].getAttribute("[ATTRIBUTE-NAME]");

No comments:

Post a Comment