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



The information in this article applies to:

  • Microsoft Excel 2002

This article was previously published under Q287076

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.

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.

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>
				

STATUS

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

MORE INFORMATION


Modification Type:MinorLast Reviewed:10/11/2006
Keywords:kbbug kbpending KB287076