aspose file tools*
The moose likes XML and Related Technologies and the fly likes XML parsing in java ..nested XML 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 "XML parsing in java ..nested XML" Watch "XML parsing in java ..nested XML" New topic
Author

XML parsing in java ..nested XML

Glory Bajaj
Greenhorn

Joined: Dec 12, 2012
Posts: 4
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
Marshal

Joined: Mar 22, 2005
Posts: 42264
    
  64
What have you tried, or -if you haven't tried anything- what were you thinking of using: DOM, SAX, XPath, ... ?


Ping & DNS - my free Android networking tools app
Glory Bajaj
Greenhorn

Joined: Dec 12, 2012
Posts: 4
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
Marshal

Joined: Mar 22, 2005
Posts: 42264
    
  64
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

Joined: Dec 12, 2012
Posts: 4
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
Marshal

Joined: Mar 22, 2005
Posts: 42264
    
  64
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

Joined: Dec 12, 2012
Posts: 4
hi,

Yes, i need java code to parse the given xml in jdk 1.4.
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12803
    
    5
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: XML parsing in java ..nested XML