This week's book giveaway is in the OCAJP forum.
We're giving away four copies of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) and have Khalid A Mughal & Rolf W Rasmussen on-line!
See this thread for details.
Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

null pointer exception

 
sreeni kadiri
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 11962
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're not supposed to call that method at all. Instead, call the parse() method.
 
sreeni kadiri
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 11962
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic