2011-11-18 43 views
10

我得到這個錯誤在我的XML文件中的文件的末尾附加內容:XML Parsing error: Extra content at the end of the documentXML解析錯誤:在

我使用記事本+ +,它顯示在標題標籤<ABC BLAH>hello</ABC BLAH>紅色第二個字 - 它顯示紅色的BLAH。因此,我假設問題出現在標題標記的空白處,並在該行引發驗證錯誤。我該如何解決這個問題?

這是XML文件:

<?xml version="1.0" encoding="UTF-8"?> 
<rows> 
    <row> 
     <Order>1</Order> 
     <Requirements>ABC</Requirements> 
     <Testing Procedures>blah blah </Testing Procedures> 
     <Assessment Observations/Comments>blah blah</Assessment Observations/Comments> <-- throws Parsing error at this line. 
    </row> 
</rows> 

回答

6
<Testing Procedures="">blah blah </Testing Procedures> 

不能有元素名稱空間。

<Assessment Observations=""/Comments>blah blah</Assessment Observations/Comments> 

另外這有多個錯誤。也許你的意思是? :

<?xml version="1.0" encoding="UTF-8"?> 
<rows> 
    <row> 
    <Order>1</Order> 
    <Requirements>ABC</Requirements> 
    <TestingProcedures foo=" ">blah blah </TestingProcedures> 
    <Assessment Observations="/ Comments>blah blah"/> 
    <Assessment Observations="/Comments"/> 
    </row> 
</rows> 

您有多個錯誤。無法真正知道你想要做什麼。

OK的.xml 101:

XML不允許在元素名稱空間。

如果不關閉元素名稱,則可以指定這樣的屬性。

<foo bar="I am an attribute" lol="Me too"> Here you can specify text, or other elements </foo> 

此外,如果一個元素不包含一個又一個,或文本,您可以使用速記符號

<foo attribute="bar"/> 

我建議你閱讀一些這方面的基本tutorial

+0

感謝您的快速回復。我是否必須在每個元素名稱中加上'=「」'空格? – input

+0

這實際上是一個從excel文件轉換而來的標頭標籤。這是正斜槓「評估觀察/評論」與數據「等」的一個要素。我知道它有錯誤,我想解決它。 – input

+0

@ fuz3d然後,你應該看看一個正確的excel頭文件標籤是怎麼樣的,並使你的.xml適合它。 – FailedDev