You can use a DOMParser
, like so:(您可以使用DOMParser
,如下所示:)
var xmlString = "<div id='foo'><a href='#'>Link</a><span></span></div>"; doc = new DOMParser().parseFromString(xmlString, "text/xml"); console.log(doc.firstChild.innerHTML); // => <div id="foo">... console.log(doc.firstChild.firstChild.innerHTML); // => <a href="#">...
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…