"Jsoup Learning Rites" parsing an HTML string

Source: Internet
Author: User
Tags baseuri

There is a problem

An HTML string from user input, a file, or a Web site, you may need to parse it and take its contents, or verify that it is in a complete format, or you want to modify it. What to do? Jsonu can help you solve these problems easily

Workaround

use static jsoup.parse (String html)   method or  jsoup.parse (string html, String baseUri) Sample code:

String html = "
Describe

parse (string html, String BaseUri)   This method can parse the input HTML into a new document ( Document), the parameter BaseUri is used to convert the relative URL to an absolute URL and specify from which Web site to obtain the documents. If this method does not apply, you can use  parse (string html)   method to parse into an HTML string as in the example above:

As long as the parse is not an empty string, you can return a well-structured document that contains (at least) a head and a BODY element.

Once you have a document, you can use the appropriate method in document or its parent class Element and Node the methods in it to get the relevant data.

Jsoup Learning Rites parsing an HTML string

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.