Click here to load reader

Peggy - XPath

  • View

  • Download

Embed Size (px)

Text of Peggy - XPath

PowerPoint Presentation


IntroductionXML (eXtensible Markup Language)XSL = Style Sheets for XMLXSL - More Than a Style Sheet LanguageXSLT (eXtensible Style Language Transform)Transform one XML to another XML or other text such as HTMLXPath (XML Path)A way to locate items in a XML fileXSL-FOA language for formatting XML documents

Css -> html 2

XPathWhat is XPath?XPath is a syntax for defining parts of an XML documentXPath uses path expressions to navigate in XML documentsXPath contains a library of standard functionsXPath is a major element in XSLTXPath is also used in XQuery, XPointer and XLinkXPath is a W3C recommendation

XPath expressions can also be used in JavaScript, Java, XML Schema, PHP, Python, C and C++, and lots of other languages.

XQueryXQuery XML XQuery XML

XLink XML XPointer XML 3

XQueryXQueryXQuery XML XQuery XML

for $x in doc(books.xml)/bookstore/book //doc(books.xml)where $x/price>30order by $x/titlereturn $x/title

XPointer and XLinkXLink XML Visit W3CXPointer XML href="'rock').child(5,item)"


XPath Relationship of NodesParentthe book element is the parent of the title and priceChildrenthe title and price elements are all children of the book elementSiblingsthe title, author, year, and price elements are all siblingsAncestorsthe ancestors of the title element are the book element and the bookstore elementDescendantsdescendants of the bookstore element are the book, title and price elements

Harry Potter 29.99 Learning XML 39.95

Si b lingAn ces torsDes cen dant7

Selecting Nodesnodename///[email protected]

Selecting Nodes - Examplebookstore bookstore /bookstore bookstore( / )bookstore/book bookstore book //book book bookstore//book bookstore book bookstore //@lang lang

Harry Potter 29.99 Learning XML 39.95

Predicates - Example/bookstore/book[1] bookstore book Note: In IE 5,6,7,8,9 first node is[0], but according to W3C, it is [1]. /bookstore/book[last()] bookstore book /bookstore/book[last()-1] bookstore book /bookstore/book[position()35.00] bookstore book price 35.00/bookstore/book[price>35.00]/title bookstore book title price 35.00

Selecting Unknown Nodes*@*node()

Selecting Unknown Nodes - Example/bookstore/* bookstore //*//title[@*] title

Selecting Several Paths - Example//book/title | /book/price book title price //title | //price title price /bookstore/book/title | //price bookstore book title price

XPath AxesLocation Path ExpressionAn absolute location path: /step/step/...A relative location path: step/step/...Each step is evaluated against the nodes in the current node-set.A step consists of:an axis (defines the tree-relationship between the selected nodes and the current node)a node-test (identifies a node within an axis)zero or more predicates (to further refine the selected node-set)



Search related