aspose file tools*
The moose likes XML and Related Technologies and the fly likes Fetch Specfic xml data from large xml file in Java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "Fetch Specfic xml data from large xml file in Java" Watch "Fetch Specfic xml data from large xml file in Java" New topic
Author

Fetch Specfic xml data from large xml file in Java

Durga Roobini
Ranch Hand

Joined: Dec 19, 2013
Posts: 105
I have an large xml files means, I merging all xml files using DOM for send to client, so it seems to be large now I want particular part from xml file how can I able achieve this please help me
I post my merge.xml file here



=========================================
<?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-062910229-4</eventid>
<title>Book cover Design</title>
<start_time>2013-11-21 19:00:00</start_time>
<venue>Kendriya Vidyalaya Gill Nagar</venue>
<city>Chennai</city>
<state>Tamil N?du</state>
<country>India</country>
</event>
<event>
<eventid>E0-001-063738775-7</eventid>
<title>National Book Week</title>
<start_time>2013-11-18 19:00:00</start_time>
<venue>Kendriya Vidyalaya Gill Nagar</venue>
<city>Chennai</city>
<state>Tamil N?du</state>
<country>India</country>
</event>
<event>
<eventid>E0-001-060871390-7</eventid>
<title>ADVANCE EXCEL TRAINING</title>
<start_time>2013-09-21 09:00:00</start_time>
<venue>Hide Out, Egmore</venue>
<city>Chennai</city>
<state>Tamil N?du</state>
<country>India</country>
</event>
<event>
<eventid>E0-001-052841520-0</eventid>
<title>Small Talk?s ?Joy of English? Winter Camp 2012</title>
<start_time>2012-12-24 10:30:00</start_time>
<venue>Chennai, IN</venue>
<city>Chennai</city>
<state>Tamil N?du</state>
<country>India</country>
</event>
<event>
<eventid>E0-001-062810772-4</eventid>
<title>Open Workshop on Selenium Test Automation Tool</title>
<start_time>2013-11-11 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-061379889-6</eventid>
<title>Master Class for Test Professionals - Robust Test Design</title>
<start_time>2013-10-17 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-055516335-8@2013041609</eventid>
<title>Balanced Scorecard Certification Training Program</title>
<start_time>2013-04-16 09:00:00</start_time>
<venue>Hotel Southern Crest</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>Satellite Symposium on "HIV CURE"</title>
<city>Chennai</city>
<country>India</country>
</eventb>
<eventb>
<eventid/>
<title>Prince2 Foundation Certification</title>
<city>Chennai</city>
<country>India</country>
</eventb>
<eventb>
<eventid/>
<title>Global Windows Azure Boot Camp - Chennai</title>
<city>Chennai</city>
<country>India</country>
</eventb>
<eventb>
<eventid/>
<title>Automotive World Megatrends India 2014</title>
<city>Chennai</city>
<country>India</country>
</eventb>
<eventb>
<eventid/>
<title>Classical Dance Programe</title>
<city>Chennai</city>
<country>India</country>
</eventb>
<eventb>
<eventid/>
<title>How to create a Second Stream of Income @Chennai</title>
<city>Chennai</city>
<country>India</country>
</eventb>
<eventb>
<eventid/>
<title>Bumper Earnings</title>
<city>Chennai</city>
<country>India</country>
</eventb>
<eventb>
<eventid/>
<title>Business analysis training @ Chennai</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>
==============================================
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41885
    
  63
Define "part". The usual approach to extracting specific information from an XML document would be to use XPath.


Ping & DNS - my free Android networking tools app
Durga Roobini
Ranch Hand

Joined: Dec 19, 2013
Posts: 105
Thanks for your idea,but am new to xml,please tell me some links and samples base on mu requirement
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41885
    
  63
You haven't said what "part" means to you like I asked, so I can't help on that with further ideas. You can find introductions to XML processing using JAXP and XPath in the http://www.coderanch.com/how-to/java/XmlFaq
Durga Roobini
Ranch Hand

Joined: Dec 19, 2013
Posts: 105
Sorry,Part means I want to fetch part of xml tags with attribute means,i want
<eventsearch>
<eventful>
<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-062910229-4</eventid>
<title>Book cover Design</title>
<start_time>2013-11-21 19:00:00</start_time>
<venue>Kendriya Vidyalaya Gill Nagar</venue>
<city>Chennai</city>
<state>Tamil N?du</state>
<country>India</country>
</event>
<event>
<eventid>E0-001-063738775-7</eventid>
<title>National Book Week</title>
<start_time>2013-11-18 19:00:00</start_time>
<venue>Kendriya Vidyalaya Gill Nagar</venue>
<city>Chennai</city>
<state>Tamil N?du</state>
<country>India</country>
</event>
<event>
<eventid>E0-001-060871390-7</eventid>
<title>ADVANCE EXCEL TRAINING</title>
<start_time>2013-09-21 09:00:00</start_time>
<venue>Hide Out, Egmore</venue>
<city>Chennai</city>
<state>Tamil N?du</state>
<country>India</country>
</event>
<event>
<eventid>E0-001-052841520-0</eventid>
<title>Small Talk?s ?Joy of English? Winter Camp 2012</title>
<start_time>2012-12-24 10:30:00</start_time>
<venue>Chennai, IN</venue>
<city>Chennai</city>
<state>Tamil N?du</state>
<country>India</country>
</event>
<event>
<eventid>E0-001-062810772-4</eventid>
<title>Open Workshop on Selenium Test Automation Tool</title>
<start_time>2013-11-11 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-061379889-6</eventid>
<title>Master Class for Test Professionals - Robust Test Design</title>
<start_time>2013-10-17 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-055516335-8@2013041609</eventid>
<title>Balanced Scorecard Certification Training Program</title>
<start_time>2013-04-16 09:00:00</start_time>
<venue>Hotel Southern Crest</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>
this much xml tags display on my browser is it possible to do in Xpath,if can means please help me..........
Swastik Dey
Rancher

Joined: Jan 08, 2009
Posts: 1477
    
    6

Do you mean your processed output should be somewhat like this
eventid: E0-001-055516202-1@2013060709
title: Six Sigma Green Belt Certification Training (Weekend)


Swastik
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41885
    
  63
So basically you want everything without the XML processing instruction and the root element?
Durga Roobini
Ranch Hand

Joined: Dec 19, 2013
Posts: 105
Ya sir I want all xml tags, actually what I did upto now is,i merge 3 xml responses from third-party webservices(i.e Eventful,zevents,eventbrite) and put it into one file, name like merge.xml -->I post this merge.xml code here first itself, after now I want extract only eventful xml responses and display in my browser.This is Possible in Xpath?
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18570
    
    8

You keep telling us how you constructed this document, but at this point it really doesn't matter where the data comes from. What does matter is this: What data do you want to extract? It seems to me that you have been asked that more than one time in this thread and so far we have no useful answer.

Perhaps you would be able to explain better if you showed us an example of the HTML you wanted to generate from that document. You did say you wanted to output the data to a browser, didn't you? So that would mean HTML.
Durga Roobini
Ranch Hand

Joined: Dec 19, 2013
Posts: 105
sorry for your repeating question am quite new to java and xml ,Based on my knowledge am replying, So I want xml formatted data ,which it is extracted from merge.xml file
for eg: assume this is my xml file
<sample>
<a>
<a1>Hai</a>
<a2>hello</a>
</a>

<b>
<b1>Nice</b1>
<b2>Meeting</b2>
<b3>You</b3>
</b>
</sample>

Now I want to extract <a> tags means,the highlighted tags I want output like as
<a>
<a1>Hai</a>
<a2>hello</a>
</a>

Please forgive me ,my explaination whether right or not ,please give me solution for my problem
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18570
    
    8

So you want to copy all elements which are elements or descendants of elements.

(You will find it easier, when working with XML, to think of elements rather than tags. Your description of your requirement shows that you want to copy the entire element and not just the tags.)

If I were doing that, I would just write an XSLT transformation which did that.

 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Fetch Specfic xml data from large xml file in Java