Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 06-14-2007, 07:03 PM   PM User | #1
Me_Titus
New Coder

 
Join Date: Apr 2006
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Me_Titus is an unknown quantity at this point
XML Validation

HI guys,

when using this property from the xmlHttpRequest "responseXML", how can one check is the xml is valid.

Thanks,

MeTitus
Me_Titus is offline   Reply With Quote
Old 06-15-2007, 07:11 AM   PM User | #2
rnd me
Senior Coder

 
rnd me's Avatar
 
Join Date: Jun 2007
Location: Urbana
Posts: 3,452
Thanks: 9
Thanked 466 Times in 450 Posts
rnd me is a jewel in the roughrnd me is a jewel in the roughrnd me is a jewel in the rough
it is typically empty if it is not...

you could also use responseText, and parse it yourself to make double sure:
Code:
 function mkXML(text) {
    if (typeof DOMParser != "undefined") {
        return (new DOMParser).parseFromString(text, "text/xml");
    } else if (typeof ActiveXObject != "undefined") {
        var doc = new ActiveXObject("MSXML2.DOMDocument");
        doc.loadXML(text);
        return doc;
    } else {
        var url = "data:text/xml;charset=utf-8," + encodeURIComponent(text);
        var request = new XMLHttpRequest;
        request.open("GET", url, false);
        request.send(null);
        return request.responseXML;
    }
}
rnd me is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 12:18 PM.


Advertisement
Log in to turn off these ads.