Convert String to XML Document in JavaScript

后端 未结 5 1513
一生所求
一生所求 2020-11-27 05:52

Saw this example on the jQuery examples page for Ajax:

var xmlDocument = [create xml document];
$.ajax({
        url: \"page.php\",
        processData: fa         


        
5条回答
  •  -上瘾入骨i
    2020-11-27 06:03

    You can do the conversion without jQuery. This is taken from Mozilla's DOMParser Documentation:

    // Create a DOMParser
    var parser = new DOMParser();
    
    // Use it to turn your xmlString into an XMLDocument
    var xmlDoc = parser.parseFromString(xmlString, "application/xml");
    

提交回复
热议问题