views:

49

answers:

1

Hi,

I hope this question (or one similar) hasn't been asked before. Sincere apologies if it has.


From an XMLHttpRequest I'm receiving an XML file like the one shown below:

<?xml version="1.0"?>
<projects>
<project>
    <department>Engineering</department>
 <primary>TNT</primary>
 <secondary>Lighting</secondary>
 <name>Project Ipsum</name>
 <description>Lorem</description>
</project>

<project>
 <department>Engineering</department>
 <primary>Heating</primary>
 <secondary>Fabric</secondary>
 <name>Project random</name>
 <description>This project is a load of</description>
</project>
.
.
.
.
</projects>

Esentially I'm trying to "query" the XML file and pull out department, primary, secondary, name, and description for any project where (for instance) primary or secondary were TNT.

Any suggestions would be greatly appreciated. Thanks again.

+1  A: 

The XMLHttpRequest object has a responseXML attribute which contains the parsed XML document. You can use standard DOM methods on it.

Lukáš Lalinský
+1 DOM methods work mostly the same on XML as they do on HTML. The W3C originally only created the DOM for XML based technologies and then applied it to HTML where applicable.