In Htmlagilitypack, Htmltextnode corresponds to a text node. This is a very simple class, with fewer methods and fields.
First, the attribute
Override string InnerHtml {get; set;} HTML code within the text (excluding itself)
Override string outerHTML {get;} HTML code for the entire text node
String Text {get; set;} Text string
Second, the method
Internal Htmltextnode (htmldocument ownerdocument, int index);
code example:
static void Main (string[] args) {//<ul class= "user_match Clear" >//<li& gt; Age: 21~30 between </li>//<li> married: Unmarried </li>//<li> region: Unlimited </li> <li> height: 175~185 cm between </li>//<li> Education: Unlimited </li>//<li> Occupation: Unlimited &L t;/li>//<li> Salary: Unlimited </li>//<li> Housing: Unlimited </li>//<li& gt; Car: Unlimited </li>//</ul> WebClient WC = new WebClient (); Wc. baseaddress = "http://www.juedui100.com/"; Wc. Encoding = Encoding.UTF8; HTMLDocument doc = new HTMLDocument (); string html = WC. Downloadstring ("user/6971070.html"); Doc. loadhtml (HTML); Htmlnode node = doc. Documentnode.selectsinglenode ("/html/body/div[4]/div[1]/div[2]/ul[1]/li[1]"); Find nodes based on XPath, similar to XmlNode//Here node is the first Li node HtMltextnode tnode = node. FirstChild as Htmltextnode; Console.WriteLine (Tnode.text); Output Age: 21~30 between Console.WriteLine (tnode.innerhtml); Output Age: 21~30 between Console.WriteLine (tnode.outerhtml); Output Age: 21~30 between strange and no change Console.readkey (); }
The Htmlcommentnode class is almost the same as the htmltextnode and is therefore no longer described.