File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes XML and Related Technologies and the fly likes null pointer exception Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "null pointer exception" Watch "null pointer exception" New topic
Author

null pointer exception

sreeni kadiri
Greenhorn

Joined: Sep 16, 2004
Posts: 2
Hi ,

I am getting null pointer exception while calling parser.getDocument(). Before that I am calling parser.startDocument() using dom parser , what are the perameters do I need to pass.Help me out.

org.apache.xerces.parsers.DOMParser;

parser.startDocument(null,"UTF-8",null,null);
return parser.getDocument();// returing null value

please reply to srinikadiri@yahoo.com



thanks

Sreeni
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
You're not supposed to call that method at all. Instead, call the parse() method.


Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
sreeni kadiri
Greenhorn

Joined: Sep 16, 2004
Posts: 2
Hi ,
I am trying to build a xml document , i don't have document to parse.Is there any alternative way to get document object.

Thanks
Sreeni
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
Originally posted by sreeni kadiri:
I am trying to build a xml document , i don't have document to parse.Is there any alternative way to get document object.

Ah. I'm not familiar with the DOMParser class myself since I never use it directly, but here's how you do it using the standard DOM API:
http://www.javaalmanac.com/egs/javax.xml.parsers/CreateDom.html
 
Consider Paul's rocket mass heater.
 
subject: null pointer exception