不断收到“文档末尾的额外内容”错误

时间:2012-09-06 23:54:15

标签: xml xml-parsing

我目前正在处理一个用于作业的xml文件,但每当我尝试在网络浏览器中打开xml文件后,继续获得“文档末尾的额外内容”,花了大约一个小时还有一半试图找出导致这种情况的原因,我仍然没有运气,所以如果有人能指出我所犯的错误或指出我正确的方向我会非常感激,谢谢! 这是xml内容本身

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<?xml-stylesheet type="text/css" href="Access Data_Phase A_Test Program.css"?>
<client_information xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="Access Data_Client Projects_Schema.xsd"/>
<client>
        <client_ID> 1 </client_ID>
        <client_name> John Hill </client_name>
        <client_address>
                <client_address_street>
                        <client_address_street_1> 123 Broad Street </client_address_street_1>
                        <client_address_street_2> Apartment 2 </client_address_street_2>
                </client_address_street>
                <client_address_city> State College </client_address_city>
                <client_address_state> PA </client_address_state>
                <client_address_zip> 16801 </client_address_zip>
        </client_address>
        <client_phone_number> 614222333 </client_phone_number>
        <client_fax_number> 6143234444 </client_fax_number>
        <client_email> jhill@ist.psu.edu </client_email>
        <project>
                <project_number> 22 </project_number>
                <contact_person>
                        <contact_person_name> Patrick Lunney </contact_person_name>
                        <contact_person_phone_number> 5554443333 </contact_person_phone_number>
                        <contact_person_fax_number> 6667778888 </contact_person_fax_number>
                        <contact_person_email> pat@email.com </contact_person_email>
                </contact_person>
                <delivery_preference> Phone </delivery_preference>
        </project>
</client>
<client>
        <client_ID> 2 </client_ID>
        <client_name> Austin Wonderly </client_name>
        <client_address>
                <client_address_street>
                        <client_address_street_1> thompson hall </client_address_street_1>
                        <client_address_street_2> room 256 </client_address_street_2>
                </client_address_street>
                <client_address_city> University Park </client_address_city>
                <client_address_state> PA </client_address_state>
                <client_address_zip> 16802 </client_address_zip>
        </client_address>
        <client_phone_number> 7167964202 </client_phone_number>
        <client_fax_number> 7815852085 </client_fax_number>
        <client_email> ajw5293@psu.edu </client_email>
        <project>
                <project_number> 44 </project_number>
                <contact_person>
                        <contact_person_name> James Wonderly </contact_person_name>
                        <contact_person_phone_number> 7169129546 </contact_person_phone_number>
                        <contact_person_fax_number> 7166560432 </contact_person_fax_number>
                        <contact_person_email> jwonderly@aholdusa.com </contact_person_email>
                </contact_person>
                <delivery_preference> Email </delivery_preference>
        </project>
</client>
<client>
        <client_ID> 3 </client_ID>
        <client_name> Mike Jones </client_name>
        <client_address>
                <client_address_street>
                        <client_address_street_1> Park Avenue Plaza </client_address_street_1>
                        <client_address_street_2> 55 East 52nd Street </client_address_street_2>
                </client_address_street>
                <client_address_city> New York </client_address_city>
                <client_address_state> NY </client_address_state>
                <client_address_zip> 10055 </client_address_zip>
        </client_address>
        <client_phone_number> 2128105300 </client_phone_number>
        <client_fax_number> 2127543123 </client_fax_number>
        <client_email> mjones@psu.edu </client_email>
        <project>
                <project_number> 4 </project_number>
                <contact_person>
                        <contact_person_name> Tom Dombrowski </contact_person_name>
                        <contact_person_phone_number> 7815553700 </contact_person_phone_number>
                        <contact_person_fax_number> 7816326000 </contact_person_fax_number>
                        <contact_person_email> tdombrowski@msn.com </contact_person_email>
                </contact_person>
                <delivery_preference> Fax </delivery_preference>
        </project>
</client>
<client>
        <client_ID> 4 </client_ID>
        <client_name> John Neale </client_name>
        <client_address>
                <client_address_street>
                        <client_address_street_1> Four Embarcadero Center </client_address_street_1>
                        <client_address_street_2> Suite 550 </client_address_street_2>
                </client_address_street>
                <client_address_city> San Francisco </client_address_city>
                <client_address_state> CA </client_address_state>
                <client_address_zip> 94111 </client_address_zip>
        </client_address>
        <client_phone_number> 8007892742 </client_phone_number>
        <client_fax_number> 6307993834 </client_fax_number>
        <client_email> jneal@statecollege.org </client_email>
        <project>
                <project_number> 6 </project_number>
                <contact_person>
                        <contact_person_name> Tom Cyran </contact_person_name>
                        <contact_person_phone_number> 6305053700 </contact_person_phone_number>
                        <contact_person_fax_number> 6307993834 </contact_person_fax_number>
                        <contact_person_email> tcyran@slrhs.com </contact_person_email>
                </contact_person>
                <delivery_preference> Phone </delivery_preference>
        </project>
</client>
</client_information>

,这也是我不断收到http://i.imgur.com/Ztg0B.png

的错误

1 个答案:

答案 0 :(得分:1)

看看错误,它准确地告诉你。第4行看起来像这样:

<client_information xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="Access Data_Client Projects_Schema.xsd"/>

然后是你的xml的其余部分。除了该行是一个封闭的节点,因此你的xml的其余部分被认为是无效的:)删除最后的闭包,如下所示:

<client_information xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="Access Data_Client Projects_Schema.xsd">