smart-fun / XmlToJson

Android Library for converting XML to JSON and JSON to XML

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Parse android xml views

ayodelekehinde opened this issue · comments

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:

<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 at the top of the file and at the bottom. Otherwise the xml is not valid.

Arnaud.