从java中的大型xml文件中获取特定的xml数据

时间:2014-01-28 10:54:28

标签: java xml

<?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>E0-001-055516202-1@2013060709</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文件特定部分我怎么能实现这一点请帮助我,我发布我的上面的xml文件

1 个答案:

答案 0 :(得分:0)

使用XML解析器

import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.DocumentBuilder;

注意以下网址

http://www.mkyong.com/java/how-to-read-xml-file-in-java-dom-parser/