[jdom-interest] SAXParser Parsing Problem

Ross Bleakney rossbleakney at hotmail.com
Wed Sep 29 16:53:11 PDT 2004

I get the following error when I parse my XML:

org.jdom.IllegalTargetException: The target "xml" is not legal for JDOM/XML 
Processing Instructions: Processing instructions cannot have a target of 
"xml" in any combination of case. (Note that the "<?xml ... ?>" declaration 
at the beginning of a document is not a processing instruction and should 
not be added as one; it is written automatically during output, e.g. by 

The xml has, of course, this at the top:

<?xml version="1.0"?>

If I remove this, something really strange happens. I get the XML inside an 
HTML document. For example, if the XML is this:


I get this (after parsing):


Here is my code:

        SAXBuilder saxBuilder = new 
        Document document = saxBuilder.build(file);

I've tried with the default parser and got the same result (I haven't tried 
other parsers).

Has anyone seen either one of these problems?


On the road to retirement? Check out MSN Life Events for advice on how to 
get there! http://lifeevents.msn.com/category.aspx?cid=Retirement

More information about the jdom-interest mailing list