xpath 从内部值中获取节点

xpath get node from inside value

当前 xpath: Product/ProductMultimediaObject/MultimediaObject

Returns:

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

        )

)

但我目前只是希望找到的 MultimediaObject 是正确的 - 但事实并非如此。我需要获取 MultimediaObject,其中 Description 具有特定值。

我尝试过的:

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

你的描述是一个属性。尝试

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

或者,简而言之,

//MultimediaObject[@Description = 'WhatIWant']