Jineeshjohn’s Blog

Parse xml document in javascript

Posted on: March 13, 2009

This function can be used for returning xml document by passing a xml String

function xmlDataLoader(xmlData) {
	if ( window.ActiveXObject ) {
		xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
		xmlDoc.async="false";
		xmlDoc.loadXML(xmlData);
		return xmlDoc; 
	}else if ( document.implementation && document.implementation.createDocument ) {
		parser=new DOMParser();
		xmlDoc=parser.parseFromString(xmlData,"text/xml");
		return xmlDoc;
	}
	return xmlObject;
}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


  • None
  • No comments yet

Categories

%d bloggers like this: