homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
Forum Library, Charter, Moderator: open

JavaScript and AJAX Forum

Best XML parsing solution?

10+ Year Member

Msg#: 3180832 posted 3:09 am on Dec 7, 2006 (gmt 0)

I've been using AJAX for a while, but I've managed until now to get around the "X" . I've just passed back what I needed from the server and used it as-is.

I'm wondering what the best way people have found to parse returned XML is? Do you use a library, and if so, which? Or is there a straightforward way of creating and parse XML from the responseText that I'm just missing?

Thanks very much!



WebmasterWorld Senior Member 5+ Year Member

Msg#: 3180832 posted 5:36 am on Dec 7, 2006 (gmt 0)

Short answer is responseXml, following handles various browser quirks

if ( typeof xh.responseXml === 'undefined' ) {
// for mozzila, should not be required, Content-Type text/xml
var parser = new DOMParser();
var doc = parser.parseFromString( xh.responseText, "text/xml" );
var XMLDoc = doc.documentElement;
else {
if ( ( xh.responseXml )
&& ( xh.responseXml.documentElement === null )
&& ( xh.responseStream) ) {
xh.responseXml.load( xh.responseStream );
var XMLDoc = xh.responseXml.documentElement;

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved