Jsoup official parsing and traversing an HTML document

Source: Internet
Author: User


How to parse an HTML document:

String html ="First parse"+"

Parsed HTML into a doc.

"; Document doc = Jsoup. parse (html );

(For more details, see parse an HTML string .)

The parser can create a clean parsing result from the HTML document you provide as much as possible, regardless of whether the HTML format is complete or not. For example, it can handle:

  • No closed tag (for example:

    Lorem

    IpsumParses

    Lorem

    Ipsum

    )
  • Implicit tag (for example, it can automaticallyTable dataPackaged
    ?)
  • Create a reliable document structure (the html Tag contains the head and body, and only the appropriate elements appear in the head ).
    • The document consists of multiple Elements and TextNodes (and other auxiliary nodes: For details, see nodes package tree ).
    • Its Inheritance structure is as follows:DocumentInheritanceElementInheritanceNode.TextNodeInheritanceNode.
    • An Element contains a child node set and has a parent Element. They also provide a unique child element filter list.

Related Article

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.