2015-10-26 90 views
-2

我有一個聚合產生這樣的輸出,但我需要從使用xpath的密鑰獲得名稱,我是新來這個XML,請指教。如何獲得xml屬性值

<Aggregation name="area"> 
     <Set key="name"> 
     <Entry key="docCount">20</Entry> 
     </Set> 
     <Set key="name1"> 
     <Entry key="docCount">16</Entry> 
     </Set> 
     <Set key="name2"> 
     <Entry key="docCount">12</Entry> 
     </Set> 
     </Aggregation> 

感謝

+0

如果你明確說明你希望從你的例子選擇精確的結果,我們可以輕鬆幫你寫的XPath它。正如你的問題所述,目前還不清楚你想要做什麼。 – kjhughes

+0

@kjhughes我已經從數據中查詢數據,並在xml中生成報告,如上所述,我想檢索每個集合的關鍵屬性。最後我做到了。讓我知道你是否知道任何好的網站來引用xpath和xml –

回答

-1

最後,我檢索的值

<Report> 
      <for-each select="$docSets" in="docSet"> 
       <Key>{$docSet/@key}</Key> 
       <Value>{$docSet//Entry/text()}</Value> 
      </for-each> 
    </Report>