Java - Read XML file from Java

Joined
May 25, 2009
Messages
2
Reaction score
0
Hello all,

I'm trying to read the contents of an XML file from my Java program.

==================================================
logDay0.xml
==================================================

<?xml version="1.0" ?>
<root gmtdate="05-22-2009" gmttime="03:45:52" totalEvents="479">
<event id="1" gmttimecode="1242884080" gmtdate="05-21-2009" gmttime="05:34:40" type="Added" category="DPI" msg="Heartbeat Lost" />
<event id="2" gmttimecode="1242884130" gmtdate="05-21-2009" gmttime="05:35:30" type="Received" category="DPI" msg="splice_insert for source 0x0, event 000061D4, program 0, avail 0 of 0" />
<event id="17" gmttimecode="1242885494" gmtdate="05-21-2009" gmttime="05:58:14" type="Received" category="DPI" msg="SCTE104 VANC message embedded for source 0x0, event 0x000061D5" />
<event id="4" gmttimecode="1242884130" gmtdate="05-21-2009" gmttime="05:35:30" type="Received" category="DPI" msg="Relay #1 triggered by SCTE35 splice_insert for Source 0x00, Event 00025044" />
<event id="7" gmttimecode="1242884130" gmtdate="05-21-2009" gmttime="05:35:30" type="Received" category="DPI" msg="GP output #2 triggered by SCTE35 splice_insert for Source 0x00, Event 00025044" />
<event id="8" gmttimecode="1242884130" gmtdate="05-21-2009" gmttime="05:35:30" type="Received" category="DPI" msg="SCTE104 VANC message embedded for source 0x0, event 0x000061D4" />
</root>
================================================== ==

I want to extract info from the tag and after some parsing, display
them as:

event id=17 gmttimecode=1242885494 gmtdate=05-21-2009 gmttime=05:58:14 type=Received category=DPI msg=SCTE104 VANC message embedded for source 0x0, event 0x000061D5
event id=8 gmttimecode=1242884130 gmtdate=05-21-2009 gmttime=05:35:30 type=Received category=DPI msg=SCTE104 VANC message embedded for source 0x0, event 0x000061D4

I don't want anything fancy, just some ability to specify a file and extract specific tags that contain msg: SCTE104 xxxx and print out the results and ignore the tags with no SCTE104. A sample java program would be helpful.


Thanks
 
Last edited:

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top