XPath - the wildcard attribute does not return an element with an attribute named value

I am trying to use XPath (Java) to get all unknown nodes based on unknown attributes starting from a specific value. For some reason, it does not return a node that contains an attribute with a name value. I also tested www.freeformatter.com/xpath-tester.html and got the same result. Here is what I have:

XML:

<div>
    <object data="/v1/assets/mp4Video-1" type="video/mp4">
        <param name="webmSource" value="/v1/assets/webmVideo-1" type="REF"/>
    </object>
</div>

XPath expression:

//*[starts-with(@*, '/v1/assets/')]

Results - returns <object>, but not <param>.

Now, if I change the XPath expression to //*[starts-with(@*, '/v1/assets/') or starts-with(@value, '/v1/assets/')], it returns both values ​​as expected.

, , value, XPath , value , ?

+4
2

:

//*[starts-with(@*, '/v1/assets/')]

, XPath 1.0 , . starts-with() node, - ( node, ).

starts-with() @* . . . XML, XPath node, . XPath ( ), -, node .

( ),

<div>
    <object data="other" type="/v1/assets/mp4Video-1">
        <param name="/v1/assets/webmVideo-1" value="other" type="REF"/>
    </object>
</div>

, , , /v1/assets/, object param. , XPath param.

, XPath! XPath .


XPath, , ,

//*[@*[starts-with(., '/v1/assets/')]]

,

, , "/v1/assets/".

+3

//@*[starts-with(., '/v1/assets/')]

//*[@*[starts-with(., '/v1/assets/')]]

.

+2

All Articles