解析XML时出错:文档元素之后的垃圾 [英] Error parsing XML: junk after document element

查看:100
本文介绍了解析XML时出错:文档元素之后的垃圾的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

hi

i得到此错误



- 解析XML时出错:文档元素后的垃圾

-there是多个垃圾根元素,第12行

i改变了< - - 到 - 因为它没有在预览中显示



(这是我的第12行)

--TextView

android:text =创建帐号

android:layout_width =match_parent

android:layout_weight =20

android :layout_height =0dp

android:textColor =#368deb

android:id =@ + id / txtCreateAccount

android :gravity =center

android:textstyle =bold

android:textSize =25sp/>



和heres我的完整代码



--LinearLayout

xmlns:android =http://schemas.android。 com / apk / res / android

android:orientation =vertical

android:layout_width =fill_parent

android:layout_height = fill_parent

android:background =@ android:color / background_light

android:weightSum =100

android:minWidth =25px

android:minHeight =25px/>





- -TextView

android:text =创建帐号

android:layout_width =match_parent

android:layout_weight =20

android:layout_height =0dp

android:textColor =#368deb

android:id =@ + id / txtCreateAccount

android:gravity =center

android:textstyle =bold

android:textSize =25sp/>





- 按钮

android:text =登录

android:layout_width =match_parent

android:layout_height =0dp

android:layout_weight =15

android:id =@ + id / btnsignin

android:paddingLeft =20dp

android:paddingRight =20dp

android:textsize =15sp/> ;





- 文本查看

android:text =或者

android:textAppearance = ?android:attr / textAppearanceMedium

android:layout_width =match_parent

android:layout_height =0dp

android:layout_weight = 15

android:id =@ + id / txtOr

android:textColor =#000

android:gravity = 中心/>



- 按钮

android:text =使用电子邮件注册

android:layout_width =match_parent

android:layout_height =0dp

android:layout_weight =15

android:id = @ + id / btnsignup

android:paddingLeft =20dp

android:paddingRight =20dp

android:textsize = 15sp/>



--RelativeLayout

android:layout_width =match_parent

android:layo ut_height =0dp

android:layout_weight =35

android:minWidth =25px

android:minHeight =25px />



--ProgressBar

style =?android:attr / progressBarStyleLarge

android: layout_width =wrap_content

android:layout_height =wrap_content

android:id =@ + id / progressBar1

android:indeterminate =true/>



- / RelativeLayout>



- / LinearLayout>



提前感谢

解决方案

你必须处理代码格式化,目前很难看到您的帖子中的XML ......但即便如此......

XML文档可以只有一个根元素



 <?  xml     version   =  1.0   编码  =  utf-8  >  
< root >
<! - 一切都在这里 - >
< / root >



 <?  xml     version   =  1.0 < span class =code-summarycomment>   encoding   =  utf-8  >  
< root >
< / root >
< root2 >
<! - 这是第二个根级元素,是错误的并且会引发错误 - >
< span class =code-keyword>< / root2 >





II尝试将您的帖子想象为XML我看到多个根元素,这是禁止的......


< blockquote>作为解决方案1的补充,我认为获得一些基本的XML知识是一个好主意。

一个地方可以在这​​里开始: W3Schools:XML教程 [ ^ ]

hi
i get this error

- Error parsing XML: junk after document element
-there are multple junk root elements , line 12
i changed the < - - to -- because it doesnt show in preview

(here is my line 12 )
--TextView
android:text="Create Account"
android:layout_width="match_parent"
android:layout_weight="20"
android:layout_height="0dp"
android:textColor="#368deb"
android:id="@+id/txtCreateAccount"
android:gravity="center"
android:textstyle="bold"
android:textSize="25sp" />

and heres my full code

--LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@android:color/background_light"
android:weightSum="100"
android:minWidth="25px"
android:minHeight="25px"/>


--TextView
android:text="Create Account"
android:layout_width="match_parent"
android:layout_weight="20"
android:layout_height="0dp"
android:textColor="#368deb"
android:id="@+id/txtCreateAccount"
android:gravity="center"
android:textstyle="bold"
android:textSize="25sp" />


--Button
android:text="Sign in"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="15"
android:id="@+id/btnsignin"
android:paddingLeft="20dp"
android:paddingRight="20dp"
android:textsize="15sp" />


--TextView
android:text="Or"
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="15"
android:id="@+id/txtOr"
android:textColor="#000"
android:gravity="center" />

--Button
android:text="Sign up with Email"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="15"
android:id="@+id/btnsignup"
android:paddingLeft="20dp"
android:paddingRight="20dp"
android:textsize="15sp" />

--RelativeLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="35"
android:minWidth="25px"
android:minHeight="25px"/>

--ProgressBar
style="?android:attr/progressBarStyleLarge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/progressBar1"
android:indeterminate="true" />

--/RelativeLayout>

--/LinearLayout>

thanks in advance

解决方案

You have to work on your code formatting, currently it is hard to see the XML in your post...But even so...
An XML document can have one, and only one, root element

<?xml version="1.0" encoding="utf-8"?>
<root>
  <!-- everything goes here -->
</root>


<?xml version="1.0" encoding="utf-8"?>
<root>
</root>
<root2>
  <!-- this is a second root-level element, which is wrong and will threw an error -->
</root2>



I I try to imagine your post as XML I see multiply root elements, and that is forbidden...


As a compliment to Solution 1, I think it is a good idea to get some basic XML knowledge.
One place to start is here: W3Schools: XML Tutorial[^]


这篇关于解析XML时出错:文档元素之后的垃圾的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆