Pregunta

I keep getting an error saying that the xml is not well formed. I have tried looking at all the other posts on this website about xml not being well formed and non of them seem to answer my question. Here is the xml code. If providing the DTDs are necessary let me know and I'll post it. The line with the error is marked.

<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>
¿Fue útil?

Solución

An XML document must have a exactly one root element.

You start with a <story>, close it, and then start another one.

Otros consejos

It is not well-formed because it has multiple top-level elements <story>.

To make it well-formed you would need to wrap the entire file with, for example

<stories>
    .. your file
</stories>
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top