0

I am new to Android development and I am wanting to parse a node only xml file using XML Resource Parser in android. I can only get it to parse an XML that contains attributes however I dont want my xml to contain attributes and I just want to pull out data contained in nodes only. Can I do this with XRP? There seem to only be methods for XML's containing attributes i.e. getAttributeValue for example

My xml looks like this:

<Streets>
<street>ABBEY WAY</street>
<district>WILLESBOROUGH</district>
<collectionday>FRIDAY</collectionday>
<jan>6,20</jan>
<feb>3,17</feb>
<mar>2,16,30</mar>
<apr>13,27</apr>
<may>11,25</may>
<jun>8,22</jun>
<jul>6,20</jul>
<aug>3,17,31</aug>
<sep>14,28</sep>
<oct>12,26</oct>
<nov>9,23</nov>
<dec>TBA</dec>
<street>ABBOTT WAY</street>
<district>TENTERDEN</district>
<collectionday>TUESDAY</collectionday>
<jan>10,24</jan>
<feb>7,21</feb>
<mar>6,20</mar>
<apr>3,17</apr>
<may>1,15,29</may>
<jun>12,26</jun>
<jul>10,24</jul>
<aug>7,21</aug>
<sep>4,18</sep>
<oct>2,16,30</oct>
<nov>13,27</nov>
<dec>TBA</dec>
<street>ACKERLEY COURT</street>
<district>STANHOPE</district>
<collectionday>THURSDAY</collectionday>
<jan>12,26</jan>
<feb>9,23</feb>
<mar>8,22</mar>
<apr>5,19</apr>
<may>3,17,31</may>
<jun>14,28</jun>
<jul>12,26</jul>
<aug>9,23</aug>
<sep>6,20</sep>
<oct>4,18</oct>
<nov>1,15,29</nov>
<dec>TBA</dec>
</Streets>

I want to create an array from the street node initially

Many thanks

4
  • 1
    Are you responsible for creating the XML source? It doesn't seem formed in a particularly logical manner. Commented Aug 6, 2012 at 14:57
  • Lol I am indeed works fine in iOS :-) Commented Aug 6, 2012 at 15:17
  • My point was really the formation of the data (not about processing it on any particular platform). One of the strengths of XML is its ability to represent objects often using nesting of nodes. Just creating a text file with tokens delimited with <> doesn't really make it XML and the format of your file really needs to be processed in a linear fashion rather than by elements with methods provided by various XML libraries. Commented Aug 6, 2012 at 15:42
  • well my XML was originally formatted with a <location id="1"> <street>ABBEY WAY</street></location> but to make the point in here I wanted to get across that I don't want attributes. Commented Aug 6, 2012 at 15:54

1 Answer 1

1

You could also use Simple for Android. It's very easy and well documented: http://simple.sourceforge.net/

IMHO a parser where I can get objects directly from a xml document is pretty neat :)

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.