>> English << | česky | Nederlands | Français | Español | По-русски | Deutsch | 中文 | Italiano | Polski ZVON > Tutorials > XPath Tutorial
>> Example 5 << | Prev | Next

Attributes are specified by @ prefix.
 
//@id
Select all attributes @id

     <AAA>
          <BBB id = "b1"/>
          <BBB id = "b2"/>
          <BBB name = "bbb"/>
          <BBB/>
     </AAA>
Open the example in XLab. | Tree view (JPG)
 
//BBB[@id]
Select BBB elements which have attribute id

     <AAA>
          <BBB id = "b1"/>
          <BBB id = "b2"/>
          <BBB name = "bbb"/>
          <BBB/>
     </AAA>
Open the example in XLab. | Tree view (JPG)
 
//BBB[@name]
Select BBB elements which have attribute name

     <AAA>
          <BBB id = "b1"/>
          <BBB id = "b2"/>
          <BBB name = "bbb"/>
          <BBB/>
     </AAA>
Open the example in XLab. | Tree view (JPG)
 
//BBB[@*]
Select BBB elements which have any attribute

     <AAA>
          <BBB id = "b1"/>
          <BBB id = "b2"/>
          <BBB name = "bbb"/>
          <BBB/>
     </AAA>
Open the example in XLab. | Tree view (JPG)
 
//BBB[not(@*)]
Select BBB elements without an attribute

     <AAA>
          <BBB id = "b1"/>
          <BBB id = "b2"/>
          <BBB name = "bbb"/>
          <BBB/>
     </AAA>
Open the example in XLab. | Tree view (JPG)