HtmlAgilityPack is used to set InnerText.

c# html-agility-pack text

Question

The InnerText property cannot be set, despite my attempts to do so using the methods below:

node.InnerText = node.InnerText.Remove(100) + ".."; 

This is because I simply want to delete words and not physical items.

<div>
    Lorem ipsum dolor sit amet, consectetur adipiscing elit.
    <img src="" />
</div>
1
8
10/8/2012 5:35:53 PM

Accepted Answer

The similar issue has suddenly arisen for me. It is evident that the documentation is read-only even if it claims get or set. But anything in between the tags is covered by the inner content. As a result, if you have 100 kids, ALL of their text, including real tags, will be there. I believe we need to utilize the Text property to accomplish what both of us are hoping to achieve. Use the Text attribute to get the actual tag.

so maybe

HtmlTextNode.Text = "";

Please be aware that only text of the HtmlTextNode type may be set.

Alternatively, I believe you could get better results if you just retain the grandkids and remove the tag.

HtmlNode.Parent.Remove(textTagYouWantRemoved, true);
6
10/19/2010 7:32:44 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