File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

New to XML, need help

 
Kajol Singh
Greenhorn
Posts: 1
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I have just started reading about XML.
I tried to run a small example on IBM'S VAJ, using DOM parser.
For some reason it does'nt work:
Here is the code:
public static void main(String[] args){
DOMParser parser = new DOMParser();
String filename = "C:/xexample.xml";
try{
parser.parse(filename);
Document doc = parser.getDocument();
} catch(Exception e)
{
System.out.println("Error in parsing" + e.getMessage());
}

}
I have classpath set and included the directory c:/ in the class path.
Could someone tell me what is wrong with this code???
Thanks,
Kaj.
 
L Goundalkar
Ranch Hand
Posts: 395
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Club the the following lines to one line of code.
try{
parser.parse(filename);
Document doc = parser.getDocument();
}
to
try{
Document doc = parser.parse(filename);
}
Thanks.
------------------
L Goundalkar
lggoundalkar@hotmail.com
Sun Certified Programmer for Java 2 Platform
 
Don't get me started about those stupid light bulbs.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic