Programming Help by Programmer's hub

Xpath Programming Language

Xpath is a XML path programming language used for the selecting nodes from the  XML document. XPath is a query language used to run the queries on the data. Xpath programming language is used to compute values from the content of an XML document. XPath was defined by the World Wide Web consortium W3C. The XPath programming language is used to create the tree representation of the XML document and allow to navigate around the tree in the document. Originally motivated by a desire to provide a common syntax and behavior model between XPointer and XSLT, subsets of the XPath query language are used in other W3C specifications such asXML Schema, XForms and the Internationalization Tag Set.

XPath Programming code example

<?xml version="1.0" encoding="utf-8"?>
<wikimedia>
  <projects>
    <project name="Wikipedia" launch="2001-01-05">
      <editions>
        <edition language="English">en.wikipedia.org</edition>
        <edition language="German">de.wikipedia.org</edition>
        <edition language="French">fr.wikipedia.org</edition>
        <edition language="Polish">pl.wikipedia.org</edition>
        <edition language="Spanish">es.wikipedia.org</edition>
      </editions>
    </project>
    <project name="Wiktionary" launch="2002-12-12">
      <editions>
        <edition language="English">en.wiktionary.org</edition>
        <edition language="French">fr.wiktionary.org</edition>
        <edition language="Vietnamese">vi.wiktionary.org</edition>
        <edition language="Turkish">tr.wiktionary.org</edition>
        <edition language="Spanish">es.wiktionary.org</edition>
      </editions>
    </project>
  </projects>
</wikimedia>
 

Functions of XPath

  • concat()
  • substring()
  • contains()
  • substring-before()
  • substring-after()
  • translate()
  • normalize-space()
  • string-length()