Microsoft KB Archive/284868

= Error message in Excel when you try to import data from a Web source: &quot;Invalid XML declaration&quot; =

Article ID: 284868

Article Last Modified on 6/27/2007

-

APPLIES TO


 * Microsoft Office Excel 2007
 * Microsoft Office Excel 2003
 * Microsoft Excel 2002 Standard Edition

-



This article was previously published under Q284868





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.



CAUSE
This behavior occurs because the Excel XML parser requires that the characters of the XML tag  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.



STATUS
Microsoft has confirmed that this is a problem in the Microsoft products that are listed in the &quot;Applies to&quot; section.



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:  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 &quot;Symptoms&quot; section of this article when used in Web queries in Excel.

Additional query words: XL2002 XL2003 XL2K3 XL2007 XL2K7 kbnoOfficeAlertID

Keywords: kbbug kberrmsg kbpending KB284868

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.