Chris
Chris

Reputation: 4364

xpath get node from inside value

Current xpath: Product/ProductMultimediaObject/MultimediaObject

Returns:

Array
(
    [0] => SimpleXMLElement Object
        (
            [@attributes] => Array
                (
                    [ContentType] => application/pdf
                    [Date] => 2014-11-01 01:20:35
                    [Description] => Leaflet
                )

        )

)

But I'm currently just hoping that the found MultimediaObject is the correct one - which is not. I need to get the MultimediaObject where Description has a specific value.

What I've tried:

Product/ProductMultimediaObject/MultimediaObject[Description/text() = 'WhatIWant']
Product/ProductMultimediaObject/MultimediaObject/Description[text() = 'WhatIWant']

Upvotes: 0

Views: 28

Answers (1)

Tomalak
Tomalak

Reputation: 338316

Your Desciption is an attribute. Try

Product/ProductMultimediaObject/MultimediaObject[@Description = 'WhatIWant']

or, for short,

//MultimediaObject[@Description = 'WhatIWant']

Upvotes: 1

Related Questions