2009-07-09 6 views

Répondre

1

De http://www.w3schools.com/Xml/xml_parser.asp (reformatée un peu):

Les charges de code suivant et parse une chaîne XML:

function loadXML(text) 
{ 
    var xmlDocument = null; 

    // Internet Explorer 
    try 
    { 
     xmlDocument = new ActiveXObject("Microsoft.XMLDOM"); 
     xmlDocument.async = false; 
     xmlDocument.loadXML(text); 
    } 
    // Standards-compliant method. 
    catch (exception) 
    { 
     parser  = new DOMParser(); 
     xmlDocument = parser.parseFromString(txt, "text/xml"); 
    } 

    return xmlDocument; 
} 

Note: Internet Explorer utilise la méthode loadXML() pour analyser une chaîne XML , tandis que d'autres navigateurs utilisent l'objet DOMParser.

Questions connexes