question

GregM avatar image
GregM asked Spirent_Admin answered

TIP: XPATH filtering on values

iTestxpath
10 |950

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
Spirent_Admin avatar image
Spirent_Admin answered
Unfortunately, XPATH does not really have the notion of wildcards, even though the following expressions might lead you to think there are: //* - list all values in an XML file //@* - list all attributs in an XML file What if you want to limit the listing based on the values or attributs themselves? There is not wildcarding in the qualifier: //*[. = 'abc*'] - give me all the nodes whose values start with "abc" But you can use the string fuctions to help out: fn:string(arg) fn:substring(string,start,len) fn:contains(string1,string2) fn:starts-with(string1,string2) fn:ends-with(string1,string2) fn:substring-before(string1,string2) fn:string-length(string) fn:lower-case(string) fn:upper-case(string) fn:normalize-space(string) fn:substring(string,start,len) fn:concat(string,string,...) So to accomplish the above example, //*[starts-with(.,'abc')] Interestingly, this will include all the nodes which include the found node, so a more appropriate search might be: //Name[starts-with(.,'main')] (Try this with the attached response map) [deviceUptime.ffrm][1] [1]: /storage/temp/3476-deviceuptime.ffrm

deviceuptime.ffrm (27.8 KiB)
10 |950

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.