我一直收到一条错误消息,说xml格式不正确。我已经尝试查看本网站上所有其他帖子关于xml没有很好的形成,他们似乎没有回答我的问题。这是xml代码。如果提供DTD是必要的,请告诉我,我会发布。标有错误的行。
<story category="national" byline="Karen Wheatley">
<headline>President Meets with Congress</headline>
<synopsis><![CDATA[
The President meet with Congressional leaders today in effort to jump-start
faltering budget negotiations. Sources described the mood of the meeting
as "cordial".
]]>
</synopsis>
<article ref="news801" />
<image src="img2071" />
</story>
<story category="international"> <!--Error is here!.-->
<headline>Relief Agencies head to Peru</headline>
<synopsis><![CDATA[
Relief agencies headed to Peru today in wake of yesterday's massive earthquake.
Initial casualty estimates top 8000, in what would be one of the most
devasting earthquakes in the last 5 years.
]]>
</synopsis>
<article ref="news802" />
<image src="img2072" />
<image src="img2073" />
</story>
<story category="national" byline="Andrew Browne">
<headline>Congress Approves Judicial Nominee</headline>
<synopsis><![CDATA[
By a vote of 55-42, the Senate approved controversial judge Sandra Lehman
to the bench of the third circuit court.
]]>
</synopsis>
<article ref="news803" />
<image src="img2074" />
</story>
<story category="sports">
<headline>Bucks grab Series Lead</headline>
<synopsis><![CDATA[
Last night, the Milwaukee Bucks defeated the Los Angles Lakers to take a
3-2 lead in the NBA finals. The series returns to Los Angeles tomorrow night,
where the Lakers have been undefeated in the playoffs.
]]>
</synopsis>
<article ref="news804" />
<image src="img2075" />
</story>
<story category="entertainment" byline="Chandra Parks">
<headline>"The Witness" tops Box Office</headline>
<synopsis><![CDATA[
"The Witness" was the top-ranked movie this week with 18M in sales. Last week's
box champ, "Another Life", fell to second with 11M in sales.
]]>
</synopsis>
<article ref="news805" />
</story>
答案 0 :(得分:2)
XML文档必须具有正好一个根元素。
您从<story>
开始,关闭它,然后再启动另一个。
答案 1 :(得分:0)
它的格式不正确,因为它有多个顶级元素<story>
。
为了使其格式良好,您需要使用例如
包装整个文件<stories>
.. your file
</stories>