title: Getting all the tags in an XML file using java
body: <p>Hi I want to get a list of all tags in an XML, and if some tags carry particular attribute I also want the value of the attribute.
  For example here are one specific examples,</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;bbc.mobile.news.view.AVGalleryView android:background="@drawable/gallery_item_selector" android:padding="2.0dip" android:focusable="true" android:layout_width="139.0dip" android:layout_height="130.0dip"
    xmlns:android="http://schemas.android.com/apk/res/android"&gt;
      &lt;bbc.mobile.news.view.NewsImageView android:id="@id/galleryItemView" android:background="#00000000" android:padding="0.0dip" android:layout_width="@dimen/thumbnail_width" android:layout_height="@dimen/thumbnail_height" /&gt;
      &lt;TextView android:textSize="13.0sp" android:textColor="@color/thumbnail_text" android:ellipsize="end" android:id="@id/articleTitleId" android:background="@color/thumbnail_text_bg" android:paddingLeft="5.0dip" android:paddingTop="2.0dip" android:paddingBottom="5.0dip" android:layout_width="139.0dip" android:layout_height="50.0dip" android:maxLines="2" android:layout_below="@id/galleryItemView" /&gt;
      &lt;ImageView android:layout_gravity="center_vertical" android:id="@id/avIconView" android:background="#99000000" android:duplicateParentState="true" android:layout_width="40.0dip" android:layout_height="40.0dip" android:src="@drawable/icon_playvideo_selected" android:layout_alignParentLeft="true" android:layout_alignParentTop="true" /&gt;
  &lt;/bbc.mobile.news.view.AVGalleryView&gt;
  </code></pre>
  
  <p>I am not interested about parent child relationship, I want to iterate to the deepest child if a parent-child relationship exists. and I also want the <strong>android:id</strong> and <strong>android:name</strong> attribute value if exists in a particular element.</p>
  
  <p>problem is that you cannot know how deep a parent-child relation can be and where in the xml it will be. And you also dont know the tag names before. I can think of using recursion in my code , but I believe there is a simpler solution</p>