2013-10-15 70 views
0

我不斷收到一個錯誤,表示xml格式不正確。我已經嘗試看看這個網站上的所有其他帖子關於XML不正常形成,他們似乎不回答我的問題。這裏是xml代碼。如果提供的DTD是必要的,讓我知道,我會張貼它。標有錯誤的行。爲什麼這個xml格式不正確?

<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

哪裏XML頭? –

+0

@ Okuma.Scott - 你的意思是''?如果您使用XML 1和UTF-8,則它是可選的。 – Quentin

+0

噢好吧。此外,我現在看到DrinkJavaCodeJava也指出了一條導致麻煩的特定線路。 –

回答

2

一個XML文檔必須有一個恰好一個根元素。

<story>開始,關閉它,然後再啓動另一個。

0

由於它有多個頂級元素<story>,因此它不是完整的。

要使它結構良好的,你會需要包裝與整個文件,例如

<stories> 
    .. your file 
</stories> 
相關問題