2010-05-31 55 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.