Titanium Community Questions & Answer Archive

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

Filter nodes by attributes

I have this xml stricture:

<?xml version="1.0" encoding="UTF-8"?>
    <elements>
        <e id="1">
            <name><![CDATA[Nationaal Visserijmuseum]]></name>
            <street><![CDATA[Pastoor Schmitzstraat]]></street>
            <number><![CDATA[5]]></number>
            <zip><![CDATA[8670]]></zip>
            <city><![CDATA[Oostduinkerke]]></city>
            <description><![CDATA[Description]]></description>
            <website><![CDATA[http://www.visserijmuseum.be/]]></website>
            <lat><![CDATA[51.1167116]]></lat>
            <lon><![CDATA[2.6823182]]></lon>
        </e>

        <e id="2">
            <name><![CDATA[Nationaal Visserijmuseum]]></name>
            <street><![CDATA[Pastoor Schmitzstraat]]></street>
            <number><![CDATA[5]]></number>
            <zip><![CDATA[8670]]></zip>
            <city><![CDATA[Oostduinkerke]]></city>
            <description><![CDATA[Description]]></description>
            <website><![CDATA[http://www.visserijmuseum.be/]]></website>
            <lat><![CDATA[51.1167116]]></lat>
            <lon><![CDATA[2.6823182]]></lon>
        </e>
    </elements>

And want the filter everything inside a node with an id attributes against a value (like 2).

var xml = THE_XML_CODE;
var e = xml.documentElement.getElementsByTagName('e').getAttribute("id") == 2;

Any ideas?

— asked June 22nd 2010 by Frederik Heyninck
  • attribute
  • filter
  • parse
  • xml
0 Comments

1 Answer

  • Have you tried Titanium.XML.parsing(xml); ?

    — answered June 22nd 2010 by Guillaume LAFOUTRY
    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.