You can use a DOMParser
, like so:
var xmlString = "<div id='foo'><a href='#'>Link</a><span></span></div>" , parser = new DOMParser() , doc = parser.parseFromString(xmlString, "text/xml"); doc.firstChild // => <div id="foo">... doc.firstChild.firstChild // => <a href="#">...
Read full article from javascript - Converting HTML string into DOM elements? - Stack Overflow
No comments:
Post a Comment