Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2

Thread: XML Validation

  1. #1
    New Coder
    Join Date
    Apr 2006
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts

    XML Validation

    HI guys,

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

    Thanks,

    MeTitus

  • #2
    Senior Coder rnd me's Avatar
    Join Date
    Jun 2007
    Location
    Urbana
    Posts
    4,302
    Thanks
    10
    Thanked 586 Times in 567 Posts
    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;
        }
    }


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •