XML:结尾部分不允许有内容
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2946528/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
XML: content is not allowed in trailing section
提问by Capsud
I'm getting these errors
我收到这些错误
Multiple annotations found at this line:
- error: Error parsing XML: not well-formed
(invalid token)
- Content is not allowed in trailing section.
on this XML file...
在这个 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>
Probably quite simple for you people who know XML. Any idea?
对于了解 XML 的人来说可能很简单。任何的想法?
回答by Paul Butcher
If you pasted it from the site you link to, there are two little hyphens you don't want. One after the close of </selector>and one just before the first <item>. Get rid of those, and all will be well.
如果您从链接到的站点粘贴它,则有两个您不想要的小连字符。一个在结束之后</selector>,一个在第一个之前<item>。摆脱这些,一切都会好起来的。
回答by patel135
<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.
回答by alien.angel
Do you have any extraneous characters after the closing tag (I'm assuming what you posted is just an excerpt from the file, since it obviously won't work without at least a closing tag)?
在结束标记之后是否有任何多余的字符(我假设您发布的内容只是文件的摘录,因为如果没有结束标记,它显然无法工作)?
回答by Dhruv
Some end tag character like '>' should be there in your xml. Remove this and error will be gone.
您的 xml 中应该有一些像“>”这样的结束标记字符。删除它,错误就会消失。

