2014-01-13 139 views
0

我想要得到這樣的XML時解析與JSoup複雜的XML文件,hovewer:解析複雜的XML與JSoup

<feed xmlns="http://www" xmlns:y="http://" xmlns:thr="http:"> 
<id>5</id> 
<title>List of friends posts</title> 
<updated>2014-01-13T18:36:06Z</updated> 
<entry> 
    <text>ttt</text> 
</entry> 
<entry> 
    <text>aaa</text> 
</entry> 
</feed> 

它沒有看到「項」子樹,就像是沒有的。 代碼:

doc3 = Jsoup.parse(doc2.toString(), "", Parser.xmlParser()); 
Elements feed = doc3.select("feed entry"); 
+0

JSoupt是HTML! – MariuszS

回答

1

這似乎工作:

String xml = "<feed xmlns=\"http://www\" xmlns:y=\"http://\" xmlns:thr=\"http:\">" 
    +"<id>5</id>" 
    +"<title>List of friends posts</title>" 
    +"<updated>2014-01-13T18:36:06Z</updated>" 
    +"<entry>" 
    +" <text>ttt</text>" 
    +"</entry>" 
    +"<entry>" 
    +" <text>aaa</text>" 
    +"</entry>" 
    +"</feed>"; 

Document doc = Jsoup.parse(xml); 
Elements feed = doc.select("feed entry"); 
+0

哦,真的!現在我意識到,問題不在JSoup中,而是在授權中。 Err..nevermind。謝謝! – Groosha