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 How can i validate? 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 "How can i validate?" Watch "How can i validate?" New topic
Author

How can i validate?

Suhas Madap
Ranch Hand

Joined: Aug 29, 2006
Posts: 52
Hi,
How can I parse a XML, validating it to the XSD using SAX parser?


Thank you,<br /> <br />Suhas K Madap<br /> <br />If you understand what you're doing, you're not learning anything."
Tom Johnson
Ranch Hand

Joined: May 11, 2005
Posts: 142
Hi Suhas,
I would suggest getting a good textbook, "Java & XML" (2nd edition) by Brett McLaughlin is an excellent introduction to XML handling with java.

As a quick intro, you need to :

1) Create an XML reader using SAX factory method


2) Define a class that implements the ContentHandler interface and register an instance of that class with the reader.


3) Create an InputSource that points to the XML file to parse


4) Set the appropriate features on the parser to turn on validation eg
<>

5) Call parse() on the reader, all event will then be sent to the object that you registered as the contentHandler.



/Tom


<a href="http://faq.javaranch.com/java/UseCodeTags" target="_blank" rel="nofollow">Use Code Tags!!</a>
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How can i validate?
 
Similar Threads
ConnectionFactory lookup returns null
Increase memory for tomcat
I've bought Sybex Java 2 Certification Virtual Trainer
Hide Standart Buttons in Taskbar
Assertion Doubt.