Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Reading XML using the XSD schema file.

 
Krishnan Sreeraman
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello guys,

I am a new bie to XML. Please suggest me some ways to read an XML file given an XSD schema file.

Thanks and Regards,
Krishnan Sreeraman.
 
amit punekar
Ranch Hand
Posts: 544
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
You can use Java and XML Binding APIs like JAXB APIS.
As you have the XSD file you can run XJC compiler and generate the Java Objects corresponding to your XML Schema.
Once done un-marshal the XML file to populate Java Tree structure from the XML input.

You can also use Castor APIs which is similar to JAXB.

Regards,
amit
 
Anutosh Swamy
Ranch Hand
Posts: 30
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Krishnan,

It seems that you want to read the contents of an XML file and display the text of each element.

If this is the case than follw this steps:

Step I : Download dom4j.jar and place this into the classpath.

Step II : Suppose the XML file is testing.xml in the test folder of your C drive.
testing.xml


Step III: The Code snippet for ReadXml.java


Hope this will solve your problem.



 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic