Htmlagilitypack: create html text node

Viewed 18946

In HtmlAgilityPack, I want to create HtmlTextNode, which is a HtmlNode (inherts from HtmlNode) that has a custom InnerText.

HtmlTextNode CreateHtmlTextNode(string name, string text)
{
     HtmlDocument doc = new HtmlDocument();
     HtmlTextNode textNode = doc.CreateTextNode(text);
     textNode.Name = name;
     return textNode;
}

The problem is that the textNode.OuterHtml and textNode.InnerHtml will be equal to "text" after the method above.

e.g. CreateHtmlTextNode("title", "blabla") will generate: textNode.OuterHtml = "blabla" instead of <Title>blabla</Title>

Is there any better way to create HtmlTextNode?

2 Answers
Related