编辑下面的代码:【加编码】
<html> <body> <script> text="<bookstore><book>"; text=text+"<title>Everyday Italian</title>"; text=text+"<author>Giada De Laurentiis</author>"; text=text+"<year>2005</year>"; text=text+"</book></bookstore>"; if (window.DOMParser) { parser=new DOMParser(); xmlDoc=parser.parseFromString(text,"text/xml"); } else // Internet Explorer { xmlDoc=new ActiveXObject("Microsoft.XMLDOM"); xmlDoc.async=false; xmlDoc.loadXML(text); } document.write("XML string is loaded into an XML DOM Object"); </script> </body> </html>
结果: 【此窗口】 帮助?
Try it Yourself - © 自强学堂