Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I certainly would not call it impossible.</p> <p>The very first solution that comes to mind is to do something like this:</p> <p>1) Insert HTML comments in your output just after opening and just before closing the <code>&lt;body&gt;</code> tag. These comments should contain a unique string so that you can search for it; a guid generated for this purpose would be a good choice. For example:</p> <pre><code>&lt;!DOCTYPE blah blah ... &lt;body&gt; &lt;!-- BODY: 3F2504E0-4F89-11D3-9A0C-0305E82C3301 --&gt; ... &lt;!-- BODY: 3F2504E0-4F89-11D3-9A0C-0305E82C3301 --&gt; &lt;/body&gt; </code></pre> <p>2) After receiving the response, search it for the two instances of <code>&lt;!-- BODY: 3F2504E0-4F89-11D3-9A0C-0305E82C3301 --&gt;</code>. Trim the string so that everything before the first and after the second instance is deleted.</p> <p>3) You now have a string that contains only elements legal inside a <code>&lt;div&gt;</code>.</p> <p>The drawback to this method is that you lose access to elements outside <code>&lt;body&gt;</code>, for example <code>&lt;title&gt;</code> (since you mention it). You will have to find another way of passing this information; there are really too many ways to go about this, so pick your poison.</p> <p><strong>Update (notes):</strong></p> <ul> <li>This solution requires that you can modify the HTML produced by <code>page-to-load.html</code> (in other words, it has to be code you own). If this is not the case, then a possibility would be to search for <code>&lt;body&gt;</code> and <code>&lt;/body&gt;</code> yourself, but that would start being bug-prone (<a href="https://stackoverflow.com/q/1732348/50079">parsing HTML with regular expressions</a>).</li> <li>Obviously, the unique string (e.g. guid above) will be chosen once and used forever without modification. The whole point is that you need to know what to search for.</li> </ul>
 

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