XmlToJson
XmlToJson copied to clipboard
Parse android xml views
I tired parsing android layout XML, but it didnt maintain hierarchy
hi! could you please attach the XML file you tried so that I can have a look? thanks!
Try parse this:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical">
<TextView
android:id="@+id/txt_hello"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:text="Hello world" />
<TextView
android:id="@+id/txt_hello"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:text="Hello world" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="@+id/txt_hello"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:text="Hello world" />
<TextView
android:id="@+id/txt_hello"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:text="Hello world" />
</LinearLayout>
Hi,
in xml format there must be 1 root element containing all the others. For example a <LinearLayout> at the top of the file and </LinearLayout> at the bottom. Otherwise the xml is not valid.
Arnaud.