我很難從JAVA中讀取來自solr的XML,現在我使用文檔和節點列表來解析XML,我需要讀取節點的每個值,並且需要讀取最後一個值eventID。這是我的Solr的XML結果:在java中讀取XML屬性
<?xml version="1.0" encoding="UTF-8"?>
<response>
<lst name="responseHeader">
<int name="status">0</int>
<int name="QTime">338</int>
</lst>
<result name="response" numFound="2" start="0">
<doc>
<long name="ID">4</long>
<int name="SourceID">2</int>
<str name="SourceTitle">EIT</str>
<str name="SourceDescription">ethichal intelligent technologies</str>
<str name="Active">1</str>
<date name="CreateDate">2006-01-17T00:00:00Z</date>
<str name="_version_">1436370186807541760</str></doc>
<doc>
<long name="ID">5</long>
<int name="SourceID">2</int>
<str name="SourceTitle">EIT</str>
<str name="SourceDescription">ethichal intelligent technologies</str>
<str name="Active">1</str>
<date name="CreateDate">2006-01-17T00:00:00Z</date>
<str name="_version_">1436370268221079552</str></doc>
</result>
</response>
在此我要讀的SourceID,SourceTitle和需要閱讀SourceDescription的最後一個屬性。 請幫幫我,怎麼弄的SourceID值(意思2),SourceTiltle值(意思EIT)這樣的..
SourceDescription沒有屬性,所以什麼是你想讀什麼書?您目前對您的代碼有什麼問題 - 即我們可以幫助您調試代碼來發現問題。還有,你有沒有使用SolrJ之類的原因? – Swati
到目前爲止你試過了什麼? – Sanghita
在這個特定的行 2 ,如何讀取值,我的意思是屬性爲SourceID,我沒有使用solrj,我得到了XML但我不知道如何提取XML –