Xpath / Find all attributes which start with specific pattern -
i want find elements there attributes start x
.
for example,
<a xt="1"> text1 </a> <a xu="2"> text2 </a> <a text1="3"> text3 </a>
the xpath find first 2 elements, because contains attributes name xt
, xu
, respectively. text1
attribute doesn't start x
, , not it.
i try start-with()
function, understood find values, , not attributes.
i use:
//*[@*[starts-with(local-name(),'x')]]
similar other answer, uses local-name()
instead. check attribute name , not namespace prefix.
for example, if use local-name()
following matched because prefix starts x
...
<a xns:text1="3" xmlns:xns="xns"> text3 </a>
if use local-name()
, not match because local name of xns:text1
text1
.
Comments
Post a Comment