Altova Mailing List Archives>Archive Index >microsoft.public.xml Archive Home >Recent entries >Thread Prev - Help with this error message, please? [Thread Next] Re: Help with this error message, please?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/ | ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
