2010-05-31 49 views
12

讓我得到這些錯誤XML:內容不會在尾隨分節

 
Multiple annotations found at this line: 
    - error: Error parsing XML: not well-formed 
    (invalid token) 
    - Content is not allowed in trailing section. 

在這個XML文件...

<selector xmlns:android="http://schemas.android.com/apk/res/android"> 
    <item 
    android:state_enabled="false" 
     android:drawable="@drawable/btn_red" /> 
    <item 
     android:state_pressed="true" 
     android:state_enabled="true" 
     android:drawable="@drawable/btn_orange" /> 
    <item 
     android:state_focused="true" 
     android:state_enabled="true" 
     android:drawable="@drawable/btn_orange" /> 
    <item 
     android:state_enabled="true" 
     android:drawable="@drawable/btn_black" /> 
</selector> 

可能是你的人,誰知道XML相當簡單。任何想法?

+1

您是否有關閉選擇器標記或這是完整的XML文件? – ronaldosantana 2010-05-31 23:54:54

+0

它的整個xml文件。我遵循本指南.. http://blog.androgames.net/40/custom-button-style-and-theme/ – Capsud 2010-05-31 23:59:03

+1

您可以使用編輯器如記事本++來檢查這些字符。檢查ANSI模式(ANSI中的編碼 - >編碼),您可以在結束標記旁看到它們。 – 2012-10-03 19:25:16

回答

21

如果您從您鏈接到的網站上粘貼它,則有兩個不需要的連字符。一個在</selector>關閉之後,一個在第一個<item>之前。擺脫這些,一切都會好的。

+0

哇......好好發現好男人:) – Capsud 2010-06-01 00:13:35

+0

你可以編輯帶有字符錯誤的XML文件嗎?這將是有用的(我有同樣的問題)。 – 2013-05-09 12:01:49

+12

無法從問題內容中發現錯誤,並且鏈接已死亡。 – sjas 2013-08-03 21:37:46

3

結束標記後面是否有任何無關字符(我假設您發佈的內容僅僅是文件的摘錄,因爲如果沒有至少一個結束標記,它顯然不起作用)?

+0

不,原因是我發佈的文件除了在那裏。我編輯我原來的帖子添加,但由於某種原因,它仍然沒有顯示 Anyway 呃這麼奇怪..? – Capsud 2010-06-01 00:07:34

0

一些結束標記字符像'>'應該在你的xml中。刪除這個,錯誤將會消失。

4
<resources> 
    <string name="app_name">Test App</string> 
</resources> 
testData("test"); 

If in any xml file unfortunately this type of line is remaining then this error is occur.