Jsoup parses an HTML string

Source: Internet
Author: User
Tags baseuri

An error occurred while parsing an HTML string.

You may need to parse a file or HTML string from a user input, retrieve its content, verify its format, or modify it. What should I do? Jsonu helps you easily solve these problems

Solution

Use staticJsoup. parse (String html)Method orJsoup. parse (String html, String baseUri)Sample Code:

String html ="First parse"+"

Parsed HTML into a doc.

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

Parse (String html, String baseUri)This method parses the entered HTML into a new Document. The baseUri parameter is used to convert the relative URL to an absolute URL and specify the website from which the Document is obtained. If this method is not applicable, you can useParse (String html)Method to parse the string into an HTML string ..

As long as the parsed string is not null, a reasonably structured document can be returned, containing (at least) a head and a body element.

Once you have a Document, you can use the appropriate method in the Document or its parent class.ElementAndNodeTo obtain the relevant data.

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.