错误:XML 文档在最终结束标记后需要开始标记

时间:2021-02-19 13:02:41

标签: xml

我收到一个 xml 错误,我知道其他地方也存在类似的问题,但我的情况没有答案。我已经运行 xmllint 告诉我需要一个起始标签......在文档的末尾。据我所知,我所有的标签都已关闭,所以我不确定它为什么期待它所期待的......

'''

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href=/Users/Andrew/Desktop/schoolwork/devicexsl.xsl>
<device>
    <phone>
        <make> Apple </make>
        <model> iPhone 12 </model>
        <OS> iOS </OS>
        <osVersion>14.4</osVersion>
        <color> Blue </color>
        <screensize> 6.1 </screensize>
        <price>€914 </price>
    </phone>
    <tablet>
        <make> Apple </make>
        <model> iPad Air </model>
        <OS> iOS </OS>
        <osVersion> 14.1 </osVersion>
        <color> Black </color>
        <screensize> 11 </screensize>
        <price> €700 </price>
    </tablet>
</device>

'''

1 个答案:

答案 0 :(得分:1)

第二行末尾缺少一个问号。

这是格式良好的 XML。

XML

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href=/Users/Andrew/Desktop/schoolwork/devicexsl.xsl?>
<device>
    <phone>
        <make>Apple</make>
        <model>iPhone 12</model>
        <OS>iOS</OS>
        <osVersion>14.4</osVersion>
        <color>Blue</color>
        <screensize>6.1</screensize>
        <price>€914</price>
    </phone>
    <tablet>
        <make>Apple</make>
        <model>iPad Air</model>
        <OS>iOS</OS>
        <osVersion>14.1</osVersion>
        <color>Black</color>
        <screensize>11</screensize>
        <price>€700</price>
    </tablet>
</device>