Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: Help with this error message, please?

From: Peter Flynn <peter.nosp@-.--------.-->
To: NULL
Date: 2/24/2009 9:41:00 PM
Ed from AZ wrote:
> We have been having some issues with our servers and with changing the
> program that reads our XML files (a proprietary report program).  We
> have several XML files that we can open with NotePad, but the report
> program throws this error:
> 
> "Only one top level element is allowed in an XML document."
> 
> Where can I go to begin understanding what this error means and how we
> might hunt it down and kill it?

What it means is easy enough. Every XML document must have one outermost 
(top-level) element and no more. So this is OK:

<?xml version="1.0"?>
<foo>stuff</foo>

but this is not:

<?xml version="1.0"?>
<foo>stuff</foo>
<foo>more stuff</foo>

If there is more than one, they should have been enclosed in a single 
outermost element, eg:

<?xml version="1.0"?>
<bar>
   <foo>stuff</foo>
   <foo>more stuff</foo>
</bar>

As to the error, you don't say what software you are using (the name of 
the parser that is throwing this error), but it may be that there isn't 
actually a second instance of the top-level element type, but just some 
crud after the end-tag of the element that is causing the parser to spit 
blood, eg

<?xml version="1.0"?>
<foo>stuff</foo>
^Z

Of course, a decent parser would report something like "character data 
not allowed after the root element", but it might also be a stray < 
character from somewhere, like this:

<?xml version="1.0"?>
<foo>stuff</foo>
<

As the < signals the start of a tag, and no more elements are allowed in 
this position, this might be enough to trip the error condition.

And it could of course be 1,001 other things too...

///Peter
-- 
XML FAQ: http://xml.silmaril.ie/


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent