What is Xpath? Examples of Xpath?

What is Xpath? Examples of Xpath?

Before we know Xpath, lets know what XML is?

What is XML?

XML abbreviation is Extensible Markup Language is a markup language similar to HTML which is designed to create information formats and share both the format and the data on the WWW (World Wide Web). It was created to provide an easy to use and store self describing data and it is self-descriptive. XML consists of text and tags which allows content to be separate from style. The tags provide rules that structure the document. XML can be read and understood by XML Parser.

  • XML Element names are case sensitive
  • XML document should have one root element
  • Elements should not overlap
  • Root Element can be called as Parent Element

Example of XML document:



  • <?xml version=”1.0″ ?> – This indicates the number of version of XML in use.
  • <?xml version=”1.0″ encoding=”ISO-8859-1″?> – This indicates the number of version of XML in use and encoding being used in the document. Types of encoding:
    • ISO-8859-1
    • UTF-8
    • UTF-16
  • XML declaration is optional. If XML is declared, it should be at the top of the document. XML declaration is case sensitive.
  • Each XML element needs to closed. Example of start tag and closed tag:
    • Start Tag     <Post>
    • Closed Tag       </Post>

What is Xpath?

Xpath is a query language that helps in addressing part of XML (Extensible Markup Language ) documents. Xpath is used to search for specific or individual elements or attributes or some parts of an XML document for a matching patterns in the document.
For example :

If you would like to just filter all the Title(s) from the entire XML document, you can do it easily with Xpath. The result would look like below:

<Title>SIP Trunk Integration with CUCM and CUC</Title>
<Title>EMCC Configuration</Title>
<Title>CUCM Asterisk SIP Trunk Integration</Title>
<Title>Cisco Unity Connection Java Error</Title>

Xpath can make life little easier.

Next Page – Click here to continue

Hope this helps!

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *