Watch This Now!

[Q] java and xml

1 posts
Thanks Meter: 0
By justinayres, Junior Member on 16th March 2014, 01:03 PM
Post Reply Subscribe to Thread Email Thread
something is wrong with my setup...

Eclipse Keplar
Windows 7 32bit
java 7u51

db = dbf.newDocumentBuilder(); throws ParserConfigurationError..
please help me. this file is as simple as i could make it.


import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;

import org.w3c.dom.Document;
import org.xml.sax.SAXException;

public class XMLHELP {

public static void main(String[] args) {

File file = new File("foo.xml");
DocumentBuilderFactory dbf;
DocumentBuilder db = null;

dbf = DocumentBuilderFactory.newInstance();
try {
db = dbf.newDocumentBuilder();
} catch (ParserConfigurationException e) {
// TODO Auto-generated catch block

try {
Document doc = db.parse(file);
} catch (SAXException e) {
// TODO Auto-generated catch block
} catch (IOException e) {
// TODO Auto-generated catch block


16th March 2014, 06:31 PM |#2  
marwan.kallal's Avatar
Junior Member
Thanks Meter: 2
ParserConfigurationError means that you misconfigured your factory.

Look here at the newInstance() method in the DocumentBuilderFactory API.
That tells you where it looks for configurations if you don't supply any. One of those files may be messed up or out of place, so give it your own configuration. I just ran the exact same code with a dummy XML file and it worked perfectly with no exceptions or errors. Look up how to configure it yourself or what the default should be, and that could fix your problem.
Post Reply Subscribe to Thread

Guest Quick Reply (no urls or BBcode)
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes