Este artículo describe el método de analizar XML por JS. Compártelo para su referencia. El método de implementación específico es el siguiente:
<script type = "javaScript"> var txt = "<note>"; txt = txt+"<TO> George </TO>"; txt = txt+"<from> John </som>"; txt = txt+"<adurning> recordatorio </heading>"; txt = txt+"<body> ¡No olvides la reunión! </body>"; txt = txt+"</note>"; if (window.domparser) // navegador no II {parser = new DomParser (); xmldoc = parser.parseFromString (txt, "text/xml"); } else // es decir, navegador {xmldoc = new ActiveXObject ("Microsoft.xmldom"); xmldoc.async = "falso"; xmldoc.loadxml (txt); } document.getElementById ("to"). innerhtml = xmldoc.getElementsBytagName ("to") [0] .childnodes [0] .nodeValue; document.getElementById ("from"). innerhtml = xmldoc.getElementsBytagName ("from") [0] .childnodes [0] .nodeValue; document.getElementById ("Mensaje"). InnerHtml = xmlDoc.getElementsBytagName ("Body") [0] .ChildNodes [0] .NodeValue; </script>Espero que este artículo sea útil para la programación de JavaScript de todos.