2010-05-14 149 views
0

我在Java中遇到了一些XML問題。以下是API調用EVE Online的結果。我如何獲得每行的「名稱」和「字符ID」?XPath獲取屬性時遇到問題

坦率地說,我不知道該從哪裏開始,所以請不要要求額外的信息。我只知道如何獲得這些屬性。

<?xml version='1.0' encoding='UTF-8'?> 
<eveapi version="1"> 
    <currentTime>2007-12-12 11:48:50</currentTime> 
    <result> 
    <rowset name="characters" key="characterID" columns="name,characterID,corporationName,corporationID"> 
     <row name="Mary" characterID="150267069" 
      corporationName="Starbase Anchoring Corp" corporationID="150279367" /> 
     <row name="Marcus" characterID="150302299" 
      corporationName="Marcus Corp" corporationID="150333466" /> 
     <row name="Dieinafire" characterID="150340823" 
      corporationName="Center for Advanced Studies" corporationID="1000169" /> 
    </rowset> 
    </result> 
    <cachedUntil>2007-12-12 12:48:50</cachedUntil> 
</eveapi> 

回答

0

嘗試

/eveapi/result/rowset/row/@name 

/eveapi/result/rowset/row/@key