Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to create DOM object from html page received over XMLHttpRequest?
    primarykey
    data
    text
    <p><strong>I'm developing a chromium extension so I have cross-host permissions for XMLHttpRequests for the domains I'm asking permissions for.</strong></p> <p>I have used XMLHttpRequest and got an HTML webpage (txt/html). I want to use XPath (document.evaluate) to extract relevant bits from it. Unfortunatly I'm failing to construct a DOM object from the returned string of the html.</p> <pre><code>var xhr = new XMLHttpRequest(); var name = escape("Sticks N Stones Cap"); xhr.open("GET", "http://items.jellyneo.net/?go=show_items&amp;name="+name+"&amp;name_type=exact", true); xhr.onreadystatechange = function () { if (xhr.readyState == 4) { var parser = new DOMParser(); var xmlDoc = parser.parseFromString(xhr.responseText,"text/xml"); console.log(xmlDoc); } } xhr.send(); </code></pre> <p><code>console.log</code> is to display debug stuff in Chromium JS console.</p> <p>In the said JS console. I get this:</p> <pre><code>Document &lt;html&gt;​ &lt;body&gt;​ &lt;parsererror style=​"display:​ block;​ white-space:​ pre;​ border:​ 2px solid #c77;​ padding:​ 0 1em 0 1em;​ margin:​ 1em;​ background-color:​ #fdd;​ color:​ black"&gt;​ &lt;h3&gt;​This page contains the following errors:​&lt;/h3&gt;​ &lt;div style=​"font-family:​monospace;​font-size:​12px"&gt;​error on line 1 at column 60: Space required after the Public Identifier ​&lt;/div&gt;​ &lt;h3&gt;​Below is a rendering of the page up to the first error.​&lt;/h3&gt;​ &lt;/parsererror&gt;​ &lt;/body&gt;​ &lt;/html&gt;​ </code></pre> <p>So how am I suppose to use XMLHttpRequest -> receive HTML -> convert to DOM -> use XPath to transverse?</p> <p>Should I be using the "hidden" iframe hack for loading / receiving DOM object?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload