This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes XML and Related Technologies and the fly likes XML Parsing Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "XML Parsing" Watch "XML Parsing" New topic
Author

XML Parsing

kk pournami
Greenhorn

Joined: May 08, 2013
Posts: 11
i have two XML's in a single file. I want to read those files and display the values of that file for ex:

File Example

1--
<book>
<bookname>ABC</bookname>
</book>

<student>
<studentid>5</studentid>
</student>


now if i parse the file Example i should get the output as

ABC
5

how can i do this???
Carles Gasques
Ranch Hand

Joined: Apr 19, 2013
Posts: 199
    
    1
Hi,

It is an XML document that is not well formatted.
I understand that any xml parser could read these two documents in one file.

You have to read the file and tokenize it with your own custom code.

Best regards,
bala nannaka
Ranch Hand

Joined: Apr 02, 2007
Posts: 49
You can take use of DOMParser class

the code looks some thing like this
kk pournami
Greenhorn

Joined: May 08, 2013
Posts: 11
I need it in DotNet.it should take all xml files read them one by one and display data ..Help me please
Mohamed Sanaulla
Saloon Keeper

Joined: Sep 08, 2007
Posts: 3068
    
  33

You want to parse the XML in a .Net language? I would suggest you to look for the language APIs present in the .Net language you are using. I am sure the language will have some implementation of a DOM parser/SAX parser. You can put some effort and search for the APIs present in the language you are using.


Mohamed Sanaulla | My Blog
kk pournami
Greenhorn

Joined: May 08, 2013
Posts: 11
Thank you for helping me out.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: XML Parsing