This question is about querying an XML file. The file structure is below:
Inline Code Example Here

<?xml version="1.0" encoding="UTF-8"?>
<descriptions>
    <image>
        <name>run.jpg</name>
        <text>Running around the lake</text>
    </image>
    <image>
        <name>sail.jpg</name>
        <text>Sailing around the lake</text>
    </image>
    <image>
        <name>track.jpg</name>
        <text>Tracking up the mountain</text>
    </image>
...
    <image>
        <name>Steven.jpg</name>
        <text>Steven Bullon is a photographer</text>
    </image>
</descriptions> 

If know the name of the picture how do I get back the text that goes with the picture?
My latest try is below, but that does not work:

   $desc = $xml->xpath('//image[name="'.$file.'"]/text');

Thanks!

I found the answer with this bit of code:

$desc = $xml->xpath('image[name="' . $file . '"]');
                    $description = $desc[0]->text;
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.