加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

解析XML XML错误解析XML文档元素后的垃圾

发布时间:2020-12-16 07:42:55 所属栏目:百科 来源:网络整理
导读:我收到这个错误: 在这一行找到多个注释: – 在根元素后面的文档中的标记必须很好, 形成. – 错误:解析XML时出错:文档元素后的垃圾 这出现在这个xml文件的第二个TextView上. ?xml version="1.0" encoding="utf-8"?TextView xmlns:android="http://schemas
我收到这个错误:

在这一行找到多个注释:
– 在根元素后面的文档中的标记必须很好,
形成.
– 错误:解析XML时出错:文档元素后的垃圾

这出现在这个xml文件的第二个TextView上.

<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
          android:id="@+id/text1" 
          android:textSize="16sp" 
          android:textStyle="bold" 
          android:textColor="#FFFF00" 
          android:layout_width="fill_parent" 
          android:layout_height="fill_parent"></TextView>

<TextView android:id="@+id/text2"
    android:textSize="12sp" 
    android:textStyle="bold" 
    android:layout_width="wrap_content" 
    android:layout_height="fill_parent"
    ></TextView>

<TextView android:id="@+id/text3" 
    android:typeface="sans"
    android:textSize="14sp"
    android:textStyle="italic"
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content"></TextView>

任何有关我所犯错误的想法?
所有的帮助是赞赏.

XML文档只能有1个根元素.你有3个这样的元素.您应该将TextView元素放在布局中,例如LinearLayout:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
              android:orientation="vertical"
              android:layout_width="match_parent"
              android:layout_height="match_parent">

    <!-- TextView elements here -->

</LinearLayout>

删除第一个TextView元素上的xmlns属性.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读