Hinchy
Hinchy

Reputation: 683

XML Javascript Question

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.

Upvotes: 0

Views: 183

Answers (1)

Luk&#225;š Lalinsk&#253;
Luk&#225;š Lalinsk&#253;

Reputation: 41306

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

Upvotes: 1

Related Questions