开发者

Android app, The markup in the document following the root element must be well-formed

开发者 https://www.devze.com 2023-03-28 11:44 出处:网络
I had started to work on some android tutorial demo\'s from below link module 6.1 Project http://www.vogella.de/articles/Android/article.html

I had started to work on some android tutorial demo's from below link module 6.1 Project http://www.vogella.de/articles/Android/article.html

Am getting following error notification in eclipse for the menu tag in below menu.xml:

The markup in the document following the root element must be well-formed.

menu.xml (path: /res/menu)

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_width="fill_parent"
    android:layout_height="fill_parent">
    <Button android:id="@+id/Button01" android:layout_width="wrap_content"
        android:layout_height="wrap_content" android:text="Show Preferences"></Button>
    <Button android:id="@+id/Button02" android:layout_width="wrap_content"
        android:layout_height="wrap_content" android:text="Change Preferences"></Button>
</LinearLayout>
   <menu xmlns:android="http://schemas.android.com/apk/res/android">
        <item android:title="Prefernces" android:id="@+id/Prefernces"></item>
</menu&开发者_如何学Gogt;

In console am getting following error:

[2011-08-17 14:47:00 - Preferences] D:\AndroidWorkSpace\Preferences\res\menu\menu.xml:10: error: Error parsing XML: junk after document element
[2011-08-17 14:47:02 - Preferences] W/ResourceType( 3524): Bad XML block: no root element node found
[2011-08-17 14:47:02 - Preferences] D:\AndroidWorkSpace\Preferences\res\menu\menu.xml:10: error: Error parsing XML: junk after document element

am i missing some thing.


Where do the last menu tag come from? You should only have one root (ie 1st level) tag, which would be LinearLayout here.


Well formed XML has one root element (this is excluding the header), so essentially what it complains about is that in your root you have two elements: LinearLayout and Menu. Wrap these in another layout element or move the menu into the LinearLayout and it should be fine.


The <menu> needs to go into its own file.

XML always has one pair of enclosing tags (e.g. <foo> </foo> where all other elements go in between. This is not the case in your example.


I agree with the diagnose, but then the error message badly needs rephrasing: "The markup in the document following the root element must be well-formed." It suggests that there can be some 'markup in the document following the root element', and that it should be well-formed. In reality the root element must not be followed by anything at all. So there is no way that any text could be well formed.

0

精彩评论

暂无评论...
验证码 换一张
取 消