HtmlAgilityPack set node InnerText
问题 I want to replace inner text of HTML tags with another text. I am using HtmlAgilityPack I use this code to extract all texts HtmlDocument doc = new HtmlDocument(); doc.Load("some path") foreach (HtmlNode node in doc.DocumentNode.SelectNodes("//text()[normalize-space(.) != '']")) { // How to replace node.InnerText with some text ? } But InnerText is readonly. How can I replace texts with another text and save them to file ? 回答1: Try code below. It select all nodes without children and filtered