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 parsin

Ok, can someone point me in the right direction in parsing an xml document? What I am looking for is what is inside 'elements' and 'node'.. the docs are really thin here.

— asked April 6th 2010 by Clint Tredway
  • iphone
  • parsing
  • xml
0 Comments

3 Answers

  • I used the Kitchen sink examples on how to parse xml etc etc. xhr_xml.js and xml_rss,js helped alot.

    — answered April 6th 2010 by Jeffrey Messick
    permalink
    0 Comments
  • Hi Clint,

    A tiny example. I have xml returned that is a list of "measurement" objects. Each measurement has an "id" attribute.

    xhr.onload = function() {
      var xml = this.responseXML;
      var measurementList = xml.documentElement.getElementsByTagName("measurement");
      for (var c=0;c < measurementList.length;c++) {
        var id_text = measurementList.item(c).getElementsByTagName("id").item(0).text;
      }
    };
    

    Hope it's useful.

    Bruce

    — answered April 6th 2010 by Bruce McTigue
    permalink
    0 Comments
  • Thanks guys. I didn't see the rss example in the KS, but after looking at that, I have it working now. Now I remember why I hate working with XML, such a pain…

    — answered April 6th 2010 by Clint Tredway
    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.