question

GregM avatar image
GregM asked Spirent_Admin answered

TIP: xpath to find preceding value

iTestxpath
show_vlan.ffrm (6.0 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.

1 Answer

·
Spirent_Admin avatar image
Spirent_Admin answered

If you want to reference a node in a different row than your key node, you can use the preceding-sibling:: axis. For example, given a table such as:

VLAN Name Status Ports ---- -------------------------------- --------- ------------------------------- 1 default active Fa0/1, Fa0/2, Fa0/4, Fa0/6, Fa0/7, Fa0/8, Gi0/1 2 VLAN0002 active 100 VLAN0100 act/lshut 1000 VLAN1000 active 1002 fddi-default act/unsup 1003 token-ring-default act/unsup 1004 fddinet-default act/unsup 1005 trnet-default act/unsup To find the VLAN id that appears before VLAN id 1000, use the expression: (//table1/table/row[VLAN='1000']/preceding-sibling::row/VLAN)[last()] Where `//table1/table/row[VLAN='1000']` will return the row with VLAN id 1000. The expression `preceding-sibling::row/VLAN` will return all of the VLAN ids before id 1000 (1 2 100). The filter `[last()]` returns only the last value in the returned list.
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.