I want to learn how to process XML with namespaces in E4X so basically here is what I want to learn, say I have some XML like this:
<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns="http://purl.org/rss/1.0/">
<rdf:item value="5"/>
<item value="10"/>
</rdf:RDF>
How could I assign <rdf:item/> to a var called rdfItems and <item/> to a var called regItems?
Thanks!
I’m not sure whether this answers the question exactly, but given your scenario, the following code retrieves both values (given the “xml” variable, referenced below, is an XML object containing the snippet of XML code you provided):
A distinction needs to be made between the “rdf” item and the “non-rdf” one, since their element names are otherwise identical, so the second namespace is declared to allow you to retrieve each item independently. Hope it helps!