I\'m developing a chromium extension so I have cross-host permissions for XMLHttpRequests for the domains I\'m asking permissions for.
I have used X
The DOMParser is choking on the DOCTYPE definition. It would also error on any other non-xhtml markup such as a <link>
without a closing /
. Do you have control over the document being sent? If not, your best bet is to parse it as a string. Use regular expressions to find what you are looking for.
Edit: You can get the browser to parse the contents of the body for you by injecting it into a hidden div:
var hidden = document.body.appendChild(document.createElement("div"));
hidden.style.display = "none";
hidden.innerHTML = /<body[^>]*>([\s\S]+)<\/body>/i(xhr.responseText)[1];
Now search inside hidden
to find what you're looking for:
var myEl = hidden.querySelector("table.foo > tr > td.bar > span.fu");
var myVal = myEl.innerHTML;