如何从DOM解析这个非有组织的xml

时间:2017-09-21 08:28:02

标签: java android dom

如何解析此描述节点? 我需要img链接和描述,你认为它是一个正确的XML解析,因为对我来说没有任何意义,

 <description><![CDATA[<img width="680" height="538"
    src="https://tctechcrunch2011.files.wordpress.com/2017/09/team1.png?w=680" class="attachment-large size-large wp-post-image" alt="" 
    srcset="https://tctechcrunch2011.files.wordpress.com/2017/09/team1.png?w=680 680w,
         https://tctechcrunch2011.files.wordpress.com/2017/09/team1.png?w=1360 1360w, 
        https://tctechcrunch2011.files.wordpress.com/2017/09/team1.png?w=150 150w, 
        https://tctechcrunch2011.files.wordpress.com/2017/09/team1.png?w=300 300w, 
        https://tctechcrunch2011.files.wordpress.com/2017/09/team1.png?w=768 768w"
         sizes="(max-width: 680px) 100vw, 680px" />&nbsp;
        DogBuddy, a pan-European online marketplace for dog sitting, has closed €5 million in Series A funding, money it plans for further expansion. Backing the London-headquartered startup in this round is existing investor Sweet Capital, the investment fund started by the founders of King.com, and a number of new unnamed private investors. It brings total raised by DogBuddy to €10 million. 
        <a href="https://techcrunch.com/2017/09/21/dogbuddy-2/?ncid=rss">Read More</a>]]></description>

我正在使用DOM

1 个答案:

答案 0 :(得分:0)

首先。

  

并且你认为它是一个正确的XML解析,因为对我来说它不是   没有任何意义,

当然是。你可以在这里测试一下https://codebeautify.org/xmlviewer

<强>第二

如果这是最终回复,那么您可以选择使用。

android.text.Html; // for html tags
android.text.Html.ImageGetter; // for html image tags parsing

类和正则表达式。希望它能起作用。