2014-01-28 45 views
1
<?xml version="1.0" encoding="UTF-8" standalone="no"?> 
<eventsearch> 
<eventful>  // I want this part of data -------->Starting 
<ObjectId>1</ObjectId> 
<event> 
<eventid>E0-001-057799040-8</eventid> 
<title>Book Fair</title> 
<start_time>2013-07-07 19:00:00</start_time> 
<venue>Chennai, IN</venue> 
<city>Chennai</city> 
<state>Tamil N?du</state> 
<country>India</country> 
</event> 
<event> 
<eventid>E0-001-061380034-0</eventid> 
<title>Master Class for Test Professionals - Effective Review of Test Cases</title> 
<start_time>2013-10-18 09:00:00</start_time> 
<venue>CleanSoft Academy</venue> 
<city>Chennai</city> 
<state>Tamil N?du</state> 
<country>India</country> 
</event> 
<event> 
<eventid>[email protected]</eventid> 
<title>Six Sigma Green Belt Certification Training (Weekend)</title> 
<start_time>2013-06-07 09:00:00</start_time> 
<venue>Hotel Southern Crest</venue> 
<city>Chennai</city> 
<state>Tamil N?du</state> 
<country>India</country> 
</event> 
</eventful> //-------------------------->Ending 
<ObjectId>2</ObjectId> 
<eventb> 
<eventid/> 
<title>UCL visit to Chennai, India - British Council EDUK Exhibition</title> 
<city>Chennai</city> 
<country>India</country> 
</eventb> 
<eventb> 
<eventid/> 
<title>Learn Ethical Hacking at BRISK Launching BISE V/2</title> 
<city>Chennai</city> 
<country>India</country> 
</eventb> 
</eventsearch> 

我有一個大的XML文件的手段,我合併使用DOM爲發送到客戶端所有的XML文件,因此它似乎是大現在我想尤其是部分從XML文件我該怎麼能夠做到這一點,請幫助我,我張貼以上獲取Java中從大的XML文件Specfic XML數據

+2

一個字:xPath –

+0

感謝您的線索,但是我對xml和Xpath有所瞭解,請向我解釋一下關於xpath的更多信息,該如何幫助我的要求 –

+0

我不知道您的java看起來如何,所以我不能爲你提供一個特定的解決方案(你可以自己google),但是在你的情況下,如果你想檢索所有的'eventful'節點,你可能需要一個xpath模式沿着'// eventful'行或者如果你只想要第一個,你可以像這樣指定它/// eventful [1]',然後你根據你選擇的xpath實現來處理它...... –

回答