简体   繁体   中英

Difference between //*/ and /*// in XPath?

I cannot figure out the difference between:

/RootNode//*/@* (1)

and

/RootNode/*//@* (2)

May be (1) says "start from the RootNode go deep as you can until you find all leaves with any attribute to print and then print it" and the (2) says "Start at RootNode , take all elements (only children of RootNode ) and then go as deep as you can until you find a leaf with an attribute to print". Am I wrong? What is the difference between (1) and (2) ?

They are both equivalent. They both say,

Select all of the attributes on elements beneath the top RootNode element.

Whether the * appears before or after the descendant-or-self step doesn't matter.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM