XML
  Home arrow XML arrow Introduction to XPath
eWeek
Iron Speed
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Dedicated Servers  
Download TestComplete 
IBM® developerWorks 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
XML

Introduction to XPath
By: Mamun Zaman
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 4
    2007-08-15

    Table of Contents:
  • Introduction to XPath
  • Path Expression Syntax
  • Getting Elements
  • Using XPath

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    Iron Speed
     
    ADVERTISEMENT

    Ajax Application Generator Generate database and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!

    Introduction to XPath
    (Page 1 of 4 )

    According to the W3C, XPath is a language for addressing parts of an XML document, designed to be used by both XSLT and XPointer. In this article we will learn about XPath, XPath expressions and how to use XPath in .NET and Java.

    XPath, XML Path Language, is an expression language for addressing portions of an XML document or navigating within an XML document. We can also get values of elements and attributes using XPath. XPath is really helpful for parsing XML- based configuration or properties files. XPath is a major element in the XSLT standard.

    XPath uses path expressions to select nodes or node-sets in an XML document. These path expressions look very much like URL and traditional file system paths. XPath also supports several functions for string manipulation, comparison and others.

    First we will learn about these path expressions. XML documents are treated as trees of nodes and the root of the tree is called the document node or root node. There are about seven different kinds of nodes. They are element, attribute, text, namespace, processing-instruction, comment, and root nodes. Usually the most used nodes are element, attribute and text. Here is an XML sample.

    <bookstore>
     
    <book>
       
    <title id='1'>XPath Tutorial</title>
        
    <author>Mamun Zaman</author>
       
    <year>2007</year>
       
    <price>00.99</price>
     
    </book>
     
    <book>
       
    <title id='2'>AJAX Tutorial</title>
       
    <author>Charles</author>
       
    <year>2007</year>
       
    <price>03.45</price>
     
    </book>
    </bookstore>

    In this XML sample, the root node is <bookstore>. We have two <book> elements; these are siblings. The <title> node is a child of the <book> element. Similarly, the <book> node is a parent of <title>, <author>, <year> and <price>. The <book> and <bookstore> nodes are ancestors of the <price> node. Similarly, the <book>, <title>, <author>, <year> and <price> nodes are descendants of <bookstore>, the root node. The id is an attribute node. The year value 2007 is a text node.

    More XML Articles
    More By Mamun Zaman


     

    XML ARTICLES

    - Path, Predicates, and XQuery
    - Using Predicates with XQuery
    - Navigating Input Documents Using Paths
    - XML Basics
    - Introduction to XPath
    - Simple Web Syndication with RSS 2.0
    - Java UI Design with an IDE
    - UI Design with Java and XML Toolkits
    - Displaying ADO Retrieved Data with XML Islan...
    - Widget Walkthrough
    - Introduction to Widgets
    - The Why and How of XML Data Islands
    - Creating an XUL App Installer
    - Overlays in XUL
    - Skinning Your Custom XUL Applications






    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway