Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to get html from an element in WebKit.Net
    primarykey
    data
    text
    <p>I'm migrating an old project to WebKit.NET 0.5 Cairo. Most roadblocks I've gotten past but I can't figure out how to get the HTML for an individual <em>WebKit.DOM.Element</em> object. </p> <p>I can read the HTML of the entire document using WebKitBrowser.DocumentText, but that is not what I need.</p> <p>Below is basically what I'm trying to accomplish. I've browsed through the docs and done a lot of searching and have come up empty on all fronts. I've found no way to accomplish the last line in the snippet.</p> <pre><code>WebKit.DOM.Element newdiv = webKitBrowser1.Document.CreateElement("DIV"); ... [ Create some SPAN's and append them to newdiv ] ... String divHTML = newdiv.DocumentText // &lt;-- DocumentText is not a member of WebKit.DOM.Element </code></pre> <p>With the IE control, I could just do <em>divHTML = newdiv.InnerHTML</em>, but can't find any equivalent to that for WebKit.NET. </p> <p>As an alternative, I would accept a solution to inject HTML into an element such that I can manually add an IMG tag without creating a DOM element specifically for it. Using divHTML.TextContent, the html is interpreted as plain text. </p> <p>Thanks in advance!</p> <p><strong>EDIT</strong> : Further trial and error has finally led to a less than optimal but functional solution in the form of</p> <pre><code>WebKit.DOM.Element newdiv = webKitBrowser1.Document.CreateElement("DIV"); ... [ Create some SPAN's and append them to newdiv ] ... String divHTML = webKitBrowser1.StringByEvaluatingJavaScriptFromString("document.getElementById('DivElementID').innerHTML"); </code></pre> <p>The same method can then also be used to set the innerHTML of an Element.</p> <p>This also solves an un-mentioned issue of WebKitBrowser.DocumentText reflecting only the original HTML and not any modified results.</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.
    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