This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes XML and Related Technologies and the fly likes Reading XML using the XSD schema file. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "Reading XML using the XSD schema file." Watch "Reading XML using the XSD schema file." New topic
Author

Reading XML using the XSD schema file.

Krishnan Sreeraman
Greenhorn

Joined: Jun 01, 2007
Posts: 12
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

Joined: May 14, 2004
Posts: 511
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


Regards,
Amit
Anutosh Swamy
Ranch Hand

Joined: Sep 20, 2007
Posts: 30

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.




K. Anutosh<br /> <br />SCJP 1.4<br />SCWCD 1.4<br />OCA (Paper I)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Reading XML using the XSD schema file.
 
Similar Threads
Validating input data passed to web service
how to generate xml file using xsd schema in java ?
XSD parsing errors
why .xsd and not .xml?
XML Schema Help