3

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>

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.

Warrior
  • 3,184
  • 12
  • 44
  • 53

4 Answers4

4

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

darma
  • 4,687
  • 1
  • 24
  • 25
3

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.

Joakim Johansson
  • 3,196
  • 1
  • 27
  • 43
1

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.

Jan de Ruiter
  • 111
  • 1
  • 5
1

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.

Heiko Rupp
  • 30,426
  • 13
  • 82
  • 119