XL2002: "Invalid XML Declaration" Error Message When You Import Data from a Web Source (284868)



The information in this article applies to:

  • Microsoft Excel 2002

This article was previously published under Q284868

SYMPTOMS

When you attempt to import data from a Web source in Microsoft Excel 2002, you may receive an error message similar to the following
File cannot be opened because:
Invalid xml declaration.
followed by lines identifying the position of the error and the Extensible Markup Language (XML) version of the file.

CAUSE

This behavior occurs because the Excel 2002 XML parser requires that the characters of the XML tag <?xml?> be absolutely the first characters on the XML page. They cannot be preceded by any other characters, even white space characters that are usually ignored by XML interpreters.

NOTE: The XML parser in Microsoft Excel 2000 does not function under these requirements.

WORKAROUND

To work around this issue, ensure that nothing whatsoever precedes the XML tag in documents that will be opened as Web data sources in Excel 2002.

STATUS

Microsoft has confirmed that this is a problem in the Microsoft products that are listed at the beginning of this article.

MORE INFORMATION

Well-formed XML documents begin with an XML declaration that identifies them as XML documents and identifies the XML version being used, as in the following example:
<?xml version="1.0"?>
				
Browsers and other programs that interpret XML generally ignore white-space characters (space, tab, or new line) in the source document, and some XML parsers ignore these characters if they occur ahead of the XML declaration. However, in the case of the XML parser included with Excel 2002, it is essential that none of these characters precede the XML declaration.

The XML parser that is included with Excel 2000, as well as with many browsers, does ignore white-space characters ahead of the XML declaration. As a result, documents that may have opened normally in those environments generate the error message described in the "Symptoms" section of this article when used in Web queries in Excel 2002.

Modification Type:MajorLast Reviewed:8/6/2001
Keywords:kbbug kberrmsg KB284868