XPath Tutorials

In this example we have created an XML file "person.xml" first, which is necessary to execute XPath query on to it.

XPath Tutorials

XPath Tutorials

     

  1. Java - XPath  Tutorial
    In this example we have created an XML file "person.xml" first, which is necessary to execute XPath query on to it. This "persons.xml" contains information related to name, age, gender of different persons.
     
  2. Use of count() function in XPath
    In the previous section of XPath in Java tutorial we have studied about how to run XPath query in java and in this section we are going to see how we can implement count() function in the XPath query.
     
  3. Use of name() function in XPath
    In the previous section of XPath in Java tutorial we have studied about how to use count() function in  XPath query and in our this section we are going to see how we can implement name() function in the XPath query.
      
  4. Use of string-length() function in XPath
    In this section we will discuss about string-length() function in XPath. string-length() function returns the number of character in a string and you can use "=","<" and ">" for comparing two numbers.
      
  5. Use of  "|" separator for selecting more than one path
    You can execute multiple expressions on an XML file with the use of XPath "|" separator. It allows you more flexibility by allowing you to execute multiple expressions at a time.
      
  6. Use of  @ for attribute in XPath
    In the previous section of XPath tutorial we have studied how to show all elements of an XML file. In this section we are describing you the use of @ for attribute in the XPath query. The "@" selects attribute.
      
  7. Using child axis in XPath expression
    In this section you will know about the use of "child axis". "child axis" consists of the children of context node. It can be omitted as well because it is the default axis you may or may not use it.
     
  8. Use of "parent" in XPath expression
    In our previous section of tutorials you have studied how to use child axis in XPath expression . Now this section will describe the use of "parent" axis. "parent" axis consists of parent of the context node.
     
  9. Use of "descendant" in XPath expression
    In this section of XPath in Java tutorial you will learn use of descendant in XPath expression. "descendant" will select descendant elements of the context element node. "descendant" are child or sub-child of a child element.
       
  10. Use of "ancestor" in XPath Expression
    As you learned about descendant axis in XPath expression in the previous example, this section will illustrate the use of ancestor in XPath expression. "ancestor" selects parent element or ancestor of the context node and super-parent of that parent.
        
  11. Use of "following" in XPath  
    In this section you will learn how to use "following" in your XPath expression. "following" axis in XPath expression will select each and every node or element following this current node closing point.
      
  12. Use of "preceding" axis in XPath expression  
    In this part of tutorial we are going to describe you the use of "preceding" axis in XPath expression. "preceding" axis will select each and every element or node before the given context node.
       
  13. Using following-sibling in XPath
    In this part of tutorial we are going to describe you how one can use "following-sibling" axis in to the XPath expression. "following-sibling" has some other working rather than "following" axis because it selects all siblings following the context node.
       
  14. Use of preceding-sibling in XPath
    In the previous sections of XPath tutorials you must have well studied about preceding, following-sibling axes. Now in this tutorial you are going to be familiar with one more axis, "preceding-sibling". "preceding-sibling" will select all the sibling elements before the context node.