jsoupa-解析遍曆一個HTML

來源:互聯網
上載者:User

標籤:對象   解析   art   int   class   document   沒有   html   文檔   

解析個遍曆一個HTML文檔

 

String html ="<html><head><title>First parse</title></head>"            +"<body><p>Parsed HTML into a doc.</p></body></html>";Document doc =Jsoup.parse(html);

  

  1. jsoup解析器能夠盡最大可能從html文檔來建立一個乾淨的解析結果,無論html的格式是否完整。
  2. jsoup可以處理如下異常情況
  3. *)沒有關閉的標籤(比如<p>Lorem<p>Ipsum parses to <p>Lorm</p><p>Ipsum</p>)
  4. *)隱式標籤(比如它可以自動將<td>Table data </td>封裝成<table><tr><td>....)
  5. *)建立可靠的文檔結果(html標籤包含head和body,在head值出現恰當的元素)
一個文檔的物件模型
  1. *)文檔由多個Elements和TextNodes組成(以及其他輔助nodes)
  2. 其繼承結構如下
  3. Document繼承Element繼承NodeTextNode繼承Node
  4. *)一個Element包含一個子節點集合,並擁有一個父Element。
  5. 還提供一個唯一的子項目過濾列表
       

 

<wiz_tmp_tag id="wiz-table-range-border" contenteditable="false" style="display: none;">

    



來自為知筆記(Wiz)



jsoupa-解析遍曆一個HTML

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.