Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

XML parsing

I have always been bad at handling XML :( I could use your info on how to parse this one

<?xml version="1.0" encoding="UTF-8"?>
<query columns="7" rows="1">
<row>
    <createdat>2010-04-13 00:00:00.0</createdat>
    <id>1</id>
    <latitude>1.12312</latitude>
    <longitude>-1.12312</longitude>
    <message>This is a test</message>
    <photourl></photourl>
    <updatedat></updatedat>
</row>
</query>

I would like to read that "rows" attribute in order to know how long my loop will be

— asked April 14th 2010 by Raul Riera
  • ajax
  • api
0 Comments

2 Answers

  • Accepted Answer

    //the following creates a list of everything contained in your row response

    var itemList = xml.documentElement.getElementsByTagName("row");
    

    //the following gets the values within your row response

    var created = itemList.item(0).getElementsByTagName("createdat").item(0).text;
    
    — answered April 15th 2010 by Ryan Gartin
    permalink
    0 Comments
  • Turns out this was the answer…

    this.responseXML.documentElement.getAttribute("rows")
    
    — answered April 14th 2010 by Raul Riera
    permalink
    0 Comments
The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.