0

我不断收到一个错误,说 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>
4

2 回答 2

2

XML 文档必须只有一个根元素。

你从一个开始<story>,关闭它,然后开始另一个。

于 2013-10-15T23:26:13.170 回答
0

它的格式不正确,因为它有多个顶级元素<story>

为了使其格式正确,您需要将整个文件包装起来,例如

<stories>
    .. your file
</stories>
于 2013-10-15T23:26:51.700 回答