Htmltextnode & Htmlcommentnode

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.