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 Parse

Trying to work through parsing the following XML return:

<resultset count="3" pstate="CA" resultType="campgrounds" waterfront="3011">
<result availabilityStatus="N" contractID="NRSO" contractType="FEDERAL" facilityID="73968" facilityName="HARVEY WEST CABIN (CA)" faciltyPhoto="/photos/details/nrso_73968_1.jpg" latitude="38.755" longitude="-120.275" sitesWithAmps="N" sitesWithPetsAllowed="N" sitesWithSewerHookup="Y" sitesWithWaterHookup="N" sitesWithWaterfront="Lakefront" state="CA"/>
<result availabilityStatus="N" contractID="NRSO" contractType="FEDERAL" facilityID="70941" facilityName="LODGEPOLE SEQUOIA NATIONAL PARK CA" faciltyPhoto="/photos/details/nrso_70941_1.jpg" latitude="36.5013889" longitude="-118.6263889" sitesWithAmps="N" sitesWithPetsAllowed="Y" sitesWithSewerHookup="Y" sitesWithWaterHookup="N" sitesWithWaterfront="Riverfront" state="CA"/>
<result availabilityStatus="N" contractID="ELS2" contractType="PRIVATE" facilityID="260861" facilityName="Wilderness Lakes Campground" faciltyPhoto="/photos/details/els2_260861_1.jpg" latitude="33.6741667" longitude="-117.1366667" sitesWithAmps="Y" sitesWithPetsAllowed="N" sitesWithSewerHookup="Y" sitesWithWaterHookup="Y" sitesWithWaterfront="Springs" state="CA"/>
</resultset>

With the following lines:

xhr.onload = function()
{
    Ti.API.info('Active xml ' + this.responseXML + ' text ' + this.responseText);
    var doc = this.responseXML.documentElement;
    var result = doc.getElementsByTagName("result");
    Ti.API.info("facility = " + result[0].getAttribute("facilityName"));

};

However the return on TI Info is "facility = null". Thoughts on what I am doing wrong to grab the facility name attribute?

— asked December 7th 2010 by Seth McGuinness
  • xhr
  • xml
  • xmlparse
1 Comment
  • is it possible that the parenthesis in the XML are causing parsing problems?

    — commented December 7th 2010 by Aaron Saunders

0 Answers

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.