Htmlagilitypack show node #text instead of span

c# html-agility-pack

Question

I've got the next html markup:

        <div>
            <span id="391d0e73-d491-4e55-9ccb-b74c6923e070">This is a text
                element</span>
        </div>

In that case, if I store this div node in anHtmlNode thereafter, when I access nodes, objectFirstChild then, as opposed to providingspan node as FirstChild giving the nodeNAME: "#text" which is missing from the markup. Please, if you could, could you assist me with this?

1
3
9/18/2012 10:48:34 AM

Accepted Answer

Nodes in XML include components, text, comments, and more. For instance, in your document, thediv may have twotext children:

<div>
    text(1) Some text could be here
    <span id="391d0e73-d491-4e55-9ccb-b74c6923e070">This is a text
        element</span>
    text(2) More text could be here
</div>

You must make it clear that you desire thespan your child elementHtmlNode , e.g.

divNode.SelectSingleNode("span")
3
9/18/2012 11:03:57 AM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow