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.

XL2002: XML File Is Treated as a Text File or a Blank File Is Opened


View products that this article applies to.

This article was previously published under Q287076

↑ Back to the top


Symptoms

When you attempt to open an Extensible Markup Language (XML) file with Microsoft Excel, one of the following behaviors may occur:
  • The file opens, but no text is displayed.

    -or-
  • Excel starts the Text Import Wizard.

↑ Back to the top


Cause

This behavior occurs when both of the following conditions are true:
  • You are opening an XML file or an XML file with an Extensible Stylesheet Language (XSL) style sheet.

    -and-
  • The XML file or XSL style sheet has a line feed or carriage return character inside a <?XML?> header or between an opening (<xsl>) and closing (</xsl>) header.

Example 1: Line Feed or Carriage Return in XML File

For example, an XML file containing the following header exhibits the behavior described in the "Symptoms" section of this article:
<?xml
version="1.0"?>
<a>
1
</a>
				

Example 2: Line Feed or Carriage Return in XSL File

The following XML file has an XSL style sheet called "employees.xsl":
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="employees.xsl"?>
<dataroot xmlns:od="urn:schemas-microsoft-com:officedata" xmlns:xsi="http://www.w3.org/2000/10/XMLSchema-instance"  xsi:noNamespaceSchemaLocation="employees.xsd">
<Employees>
<EmployeeID>1</EmployeeID>
<LastName>Davolio</LastName>
<FirstName>Nancy</FirstName>
</Employees>
</dataroot>
				
If "employees.xsl" contains the following text, the following behavior is exhibited when you open the XML file and specify to apply the style sheet:
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl" language="vbscript">
<xsl:template match="/">
<xsl:pi name="xml"> version="1.0" 
</xsl:pi>
<Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet" xmlns:n1="urn:schemas-microsoft-com:office:spreadsheet">
<Worksheet n1:Name="Employees">
</Worksheet>
</Workbook>
</xsl:template>
</xsl:stylesheet>
				
NOTE: The line that begins with <xsl:pi> has a carriage return before the </xsl:pi> header.

↑ Back to the top


Resolution

To resolve this issue, edit the XML files and XSL style sheets to remove all carriage-return and line-feed characters from between the starting and ending headers. The preceding examples work correctly if changed to the following:

Example 1

<?xml version="1.0"?>
<a>
1
</a>
				

Example 2

<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl" language="vbscript">
<xsl:template match="/">
<xsl:pi name="xml"> version="1.0" </xsl:pi>
<Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet" xmlns:n1="urn:schemas-microsoft-com:office:spreadsheet">
<Worksheet n1:Name="Employees">
</Worksheet>
</Workbook>
</xsl:template>
</xsl:stylesheet>
				

↑ Back to the top


Status

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

↑ Back to the top


Keywords: KB287076, kbpending, kbbug

↑ Back to the top

Article Info
Article ID : 287076
Revision : 7
Created on : 1/31/2007
Published on : 1/31/2007
Exists online : False
Views : 242