"Rico" <> wrote in message
news

...
> The following piece of code :
>
> DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory
> .newInstance();
> DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
> Document doc = docBuilder.parse(filename);
>
>
> ends in "Document root element is missing" for the following XML:
>
> <?xml version="1.0" encoding="utf-8"?>
> <EmailSender>
> <db_name>master</db_name>
> <document_type>document_New</document_type>
> <emailID />
> <document_ID>23983</document_ID>
> </EmailSender>
>
>
> I don't really know how the XML is being produced but a space between the
> last double-quote and the last '?' seems to solve the problem.
> So does changing double-quotes to single-quotes.
>
> Is it something wrong with the XML document or am I missing something
> about the usage of the API ?
The first line of the XML file is not XML syntax.
That's according to the rules of XML.
<?xml version='1.0' encoding='UTF-8' ?>
The first line above is an example of a correct
XML header. It is *not* XML, because the keywords
must be specified in the correct order. (Attribute
keywords that appear within the XML body can be
specified in any order.) I use single quotes in
preference to double quotes, but the space appearing
before the final ? is required.