Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

XML parsing in java ..nested XML

 
Glory Bajaj
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I want to retrieve values in java of follwing xml:

<Books>
<BookName>
<idBookName>BookNameAlta1</idBookName>
<Subject>
<value>001</value>
<status>ON</status>
</Subject>
</BookName>
<BookName>
<idBookName>BookNameAlta2</idBookName>
<Subject>
<value>004,009,010,112</value>
<status>OFF</status>
</Subject>
</BookName>
<BookName>
<idBookName>BookNameAlta3</idBookName>
<Subject>
<value>005</value>
<status>OFF</status>
</Subject>
<Subject>
<value>RESTO</value>
<status>ON</status>
</Subject>
</BookName>
</Books>


Can you please help..
Thankss...
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What have you tried, or -if you haven't tried anything- what were you thinking of using: DOM, SAX, XPath, ... ?
 
Glory Bajaj
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have not yet tried anything, but i have seen DOM parser is more easy, i need java build in library to use this.
I am new to this thing..Thinking of using DOM parser.

Thanks
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
DOM, SAX and XPath are all built into the JRE. If it's just the data within the value tags, XPath might be the easiest approach.
 
Glory Bajaj
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ulf Dittmer wrote:DOM, SAX and XPath are all built into the JRE. If it's just the data within the value tags, XPath might be the easiest approach.


Hi,

I actually need to Map this XML to a database table.need to fill values in Database table. Thinking this requiremnet ,Can you please help.
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So is the problem XML parsing, or something DB related? It doesn't sound as if both are related, so let's stick to XML parsing in this topic. Once you have the data extracted form the XML, and are encountering problems storing them in a DB, you can then start a new topic in the JDBC/SQL forum.
 
Glory Bajaj
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,

Yes, i need java code to parse the given xml in jdk 1.4.
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13071
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Glory Bajaj wrote:hi,

Yes, i need java code to parse the given xml in jdk 1.4.


Well thats going to be a bad idea. The Java Api for Xml Processing JAXP has undergone a number of changes and Java 1.4 is way out of date. Java 1.4 hit end of life 4 years ago.

You might as well update to version 7 since version 6 is ending also.

Bill
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic