0
希望有人能夠提供幫助,並解決其簡單問題。我的代碼在運行代碼的當前輸出下面。需要使用Sax XML解析從特定元素開始的XML
public void startElement(String uri, String localName , String qName,
Attributes attributes) throws SAXException {
if(!localName.matches("characterID")) {
String Primary = attributes.getValue("characterID");
System.out.println("ROOAR:" + Primary);
} else {
System.out.println("ROOAR:" + localName);
}
Output
ROOAR:null
ROOAR:null
ROOAR:null
ROOAR:null
ROOAR:92916469
ROOAR:95325415
ROOAR:95528725
ROOAR:null
我想知道我可以具體如何startElement在指定的子元素。現在,它開始於根元素,但我寧願從第5行開始,因爲它有它自己的子元素。
示例XML
<eveapi version="2">
<currentTime>2015-08-14 22:44:09</currentTime>
<result>
<rowset name="characters" key="characterID" columns="name,characterID,corporationName,corporationID,allianceID,allianceName,factionID,factionName">
<row name="Grasume" characterID="95528725" corporationName="School of Applied Knowledge" corporationID="1000044" allianceID="0" allianceName="" factionID="0" factionName="" />
</rowset>
</result>
<cachedUntil>2015-08-14 23:03:33</cachedUntil>
</eveapi>
在您的問題中添加示例輸入。這有助於更好地理解你的問題。 –