0

我对这个 XML 和网络世界真的很陌生。如果有人可以帮助我,我将不胜感激。这可能只是一个小错误,但我找不到解决方法。它。我编写了一个 XML 文档,但收到一条错误消息:

此页面包含以下错误:

第 6 行第 1 列的错误:文档末尾的额外内容


<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/css" href="student_faculty_directory.css"?>
<haccdirectory xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="student_faculty_directory_Schema.xsd" />


<haccdirectory> <!--this is where the ERROR occurs-->
<s:student xmlns:s="http://www.hacc.info.edu/student=dir">
    <class101>
        <s:name>Austin Tang</s:name>
            <s:info>
                <s:age>28</s:age>
                <s:gender>Male</s:gender>
                <s:major>Web Development</s:major>
                <s:enrollment>SPR12</s:enrollment>
                <s:transferstudent>No</s:transferstudent>
                <s:id>H01179944</s:id>
            </s:info>
        <s:name>Jeremy Riddle</s:name>
            <s:info>
                <s:age>21</s:age>
                <s:gender>Male</s:gender>
                <s:major>Web Design</s:major>
                <s:enrollment>SPR13</s:enrollment>
                <s:transferstudent>Yes</s:transferstudent>
                <s:id>H01539441</s:id>
            </s:info>
        <s:name>Debbie Scissors</s:name>
            <s:info>
                <s:age>19</s:age>
                <s:gender>Male</s:gender>
                <s:major>Web Development</s:major>
                <s:enrollment>FAL14</s:enrollment>
                <s:transferstudent>No</s:transferstudent>
                <s:id>H01570984</s:id>
            </s:info>
        <s:name>Craig Davidson</s:name>
            <s:info>
                <s:age>22</s:age>
                <s:gender>Male</s:gender>
                <s:major>Web Development</s:major>
                <s:enrollment>SPR14</s:enrollment>
                <s:transferstudent>Yes</s:transferstudent>
                <s:id>H01578433</s:id>
            </s:info>
        <s:name>Justin Beer</s:name>
            <s:info>
                <s:age>24</s:age>
                <s:gender>Male</s:gender>
                <s:major>Web Design</s:major>
                <s:enrollment>SPR13</s:enrollment>
                <s:transferstudent>No</s:transferstudent>
                <s:id>H01091349</s:id>
            </s:info>
        <s:name>Melody Herman</s:name>
            <s:info>
                <s:age>19</s:age>
                <s:gender>Female</s:gender>
                <s:major>Web Design</s:major>
                <s:enrollment>SPR12</s:enrollment>
                <s:transferstudent>No</s:transferstudent>
                <s:id>H01992341</s:id>
            </s:info>
    </class101>
</s:student>

<f:faculty xmlns:f="http://www.hacc.info.edu/faculty-dir">
    <teacher>
        <f:name>Andre Miller</f:name>
            <f:information>
                <f:age>39</f:age>
                <f:gender>Male</f:gender>
                <f:hiredate>2003-05-23</f:hiredate>
                <f:id>H01908314</f:id>
                <f:campus>Lancaster</f:campus>
            </f:information>
        <f:name>Melody Wright</f:name>
            <f:information>
                <f:age>32</f:age>
                <f:gender>Female</f:gender>
                <f:hiredate>2002-07-12</f:hiredate>
                <f:id>H01809312</f:id>
                <f:campus>Gettysburg</f:campus>
            </f:information>
        <f:name>Andrew Yoder</f:name>
            <f:information>
                <f:age>44</f:age>
                <f:gender>Male</f:gender>
                <f:hiredate>2001-08-12</f:hiredate>
                <f:id>H01782354</f:id>
                <f:campus>Harrisburg</f:campus>
            </f:information>
        <f:name>Heather Miller</f:name>
            <f:information>
                <f:age>50</f:age>
                <f:gender>Female</f:gender>
                <f:hiredate>2001-07-31</f:hiredate>
                <f:id>H01742121</f:id>
                <f:campus>Harrisburg</f:campus>
            </f:information>
        <f:name>Stephanie King</f:name>
            <f:information>
                <f:age>37</f:age>
                <f:gender>Female</f:gender>
                <f:hiredate>2012-09-01</f:hiredate>
                <f:id>H01922111</f:id>
                <f:campus>Lancaster</f:campus>
            </f:information>
        <f:name>Robert Freeman</f:name>
            <f:information>
                <f:age>31</f:age>
                <f:gender>Male</f:gender>
                <f:hiredate>2014-09-10</f:hiredate>
                <f:id>H01801154</f:id>
                <f:campus>Gettysburg</f:campus>
            </f:information>
        <f:name>Casey Stevenson</f:name>
            <f:information>
                <f:age>31</f:age>
                <f:gender>Female</f:gender>
                <f:hiredate>2014-05-30</f:hiredate>
                <f:id>H01642029</f:id>
                <f:campus>Harrisburg</f:campus>
            </f:information>
    </teacher>
</f:faculty>
</haccdirectory>
4

1 回答 1

1

第 3 行的斜杠表示您在同一个声明中打开和关闭了根元素。

XML 解析器告诉您,该文档的顶部有一个非常简单的文档,它是:

<haccdirectory xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
               xsi:schemaLocation="student_faculty_directory_Schema.xsd" />

之后的一切都只是额外的垃圾。

我认为斜杠不应该在那里。

于 2015-05-09T12:11:00.313 回答