Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

Error message in Excel when you try to import data from a Web source: "Invalid XML declaration"


Symptoms

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

↑ Back to the top


Cause

This behavior occurs because the Excel 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.

↑ Back to the top


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.

↑ Back to the top


Status

Microsoft has confirmed that this is a problem in the Microsoft products that are listed in the "Applies to" section.

↑ Back to the top


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, 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.

↑ Back to the top


Keywords: kb, kbpending, kberrmsg, kbbug, kbfreshness2006, kboffice12yes

↑ Back to the top

Article Info
Article ID : 284868
Revision : 8
Created on : 8/20/2020
Published on : 8/21/2020
Exists online : False
Views : 128