开发者

Parsing error for XML created with WordPad

开发者 https://www.devze.com 2023-02-19 10:16 出处:网络
I have creat开发者_运维百科ed a simple xml file called \"class\" and saved it to my desktop <?xml version=\"1.0\" encoding=\"UTF-8\"?>

I have creat开发者_运维百科ed a simple xml file called "class" and saved it to my desktop

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="class.xsl"?>
<class>
    <student>Jack</student>
    <student>Harry</student>
    <student>Rebecca</student>
    <teacher>Mr. Bean</teacher>
</class>

Then I created an xsl file to do some xslt called "class.xsl" and saved it to my desktop

<?xml version="1.0" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="class">
    <html>
    <body>
    <xsl:apply-templates select="student"/>
    </body>
    </html>
</xsl:template>
<xsl:template match="student">
    <p>
    Found a learner!
    </p>
</xsl:template>
</xsl:stylesheet>

When I click on the class.xml file and it trys to load it in internet explorer and gives me the following error:

The XML page cannot be displayed 

    Cannot view XML input using style sheet. Please correct the error and then click the Refresh button, or try again later. 


    --------------------------------------------------------------------------------

    Invalid at the top level of the document. Error processing resource 'file:///C:/Documents and Settings/nlamarca/Desktop/cla...

    {\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fswiss\fcharset0 Arial;}}
    ^

What am I doing wrong here?


You need to save it in text format. You have probably used MS Word or Wordpad or similar to edit the code. When you save it it is saves in the RTF format. This format is not suitable for the task you are trying to perform.

Either

  1. Use another text editor, such as notepad, notepad++ etc.
  2. Figure out how to save it in plain text format in your current editor
0

精彩评论

暂无评论...
验证码 换一张
取 消