XPath several different key concepts

XPath several different key concepts ......

Absolute vs relative XPath ( /vs  .)

  • / The introduction of absolute location path, starting from the root of the document.

  • . From the introduction of the context node start position relative path.

Naming any element elements VS ( enameVS  *)

  • /enameSelect a enameroot element

    • ./enameSelect enameall child elements of the current node.

  • /* Select the root element, regardless of the name.

    • ./*Or *select all children of the context node, regardless of the name.

Descendant or self axis //*( )

  • //enameSelect enameall elements in the document.

    • .//enameSelect enamecontext node or in all elements.

  • //* Select all elements in the document, regardless of the name.

    • .//* Select all the elements of the context node or below, regardless of the name.


Taking into account these concepts, here are answers to your specific questions ......

  • .//*[@id='Passwd']Indicating the selection or the current context node having idall the elements of the property is equal 'Passwd'.

  • //child::input[@type='password']It can be simplified,  //input[@type='password']and means selecting inputa document typeall elements of property values equal 'password'.

 

 / AAA / BBB / following-sibling :: * after taking all the sibling nodes / AAA / BBB node

 

 

 reference:

http://www.imooc.com/wenda/detail/579577

https://www.cnblogs.com/zhaozhan/archive/2009/09/10/1564332.html

Guess you like

Origin www.cnblogs.com/pu369/p/11686826.html