Reputation: 1831
var
parser = new DOMParser(),
d = parser.parseFromString('<?xml version="1.0"?><div class="a">Hello</div>', 'application/xhtml+xml');
console.log(d.querySelector('*'));
console.log(d.querySelector('div'));
console.log(d.querySelector('div.a'));
The first two selectors work
The last selector.... the class selector.... returns null :(
Any ideas why?
Needing this to query html results from AJAX, and dont want to add it to the main DOM to do so.
Upvotes: 1
Views: 92
Reputation: 19707
Because your html/xml is invalid. Try changning </a>
to </div>
Upvotes: 3