18

XPath

Embed Size (px)

DESCRIPTION

XPath

Citation preview

Page 1: XPath
Page 2: XPath
Page 3: XPath
Page 4: XPath

P P L

Page 5: XPath

D:\Web Technologies\Xml

Page 6: XPath
Page 7: XPath

/

/child::Contacts/child::Contact[@id=3]/child::phone

axis

node test

predicate

Page 8: XPath

• child axis

• attribute axis

• ancestor axis

• ancestor-or-self axis

• descendant axis

• descedant-or-self axis

• following axis

• following-sibling axis

• namespace axis

• parent axis

• preceding axis

• preceding-sibling axis

• self axis

Page 9: XPath

self

parent

ancestor

ancestor-or-self

following-sibling

following

preceding-sibling

preceding

child

descendant

descendant-or-seft

Page 10: XPath

• //Contact[@id=3]

• //Contact[@title=“Mr”][@age>25]

Page 11: XPath

• Boolean boolean(arg) //returns false if object equal to zero/NaN/empty

• Boolean false() //returns the Boolean value false

• Boolean lang(string arg) //to check language which is used in context node

• Boolean not(arg) //

• Boolean true() // returns the Boolean value true

Page 12: XPath

• number count(node-set arg) //returns the number of nodes

• node-set id(string arg) //returns a node-set

• last() // returns a value equal to the context size

• string local-name(optional node-set arg) //returns local name(context node)

• string name(optional node-set arg) //returns the nam of node in QName format

• string namespace-uri(optional node-set arg) //returns namespace-uri of node-set

• Number position() //returns value equal to the context position

Page 13: XPath

• number ceiling( number arg) //returns the smallest integer greater than this

• number floor(number arg) //returns the largest integer that is lower than this

• number number(arg) //to convert string, Boolean, node-set to number

//returns NaN if can not convert

• number round(number arg) //returns the integer that is closest to the number arg

• number sum(node-set arg) // return sum of node in node-set

// return NaN if node can’t converted to number

Page 14: XPath

• string concat(string arg1, arg2) //returns the concatenation of those strings

• Boolean contains(string arg1, arg2) //returns true if arg1 contains arg2

• string normalize-space(string arg1) //=trim & replace whitespace=single space

• Boolean start-with(string arg1, arg2) //returns true if arg1 starts with arg2

• string string(arg) //to convert Boolean, node-set, number to string

• number string-length(string arg) //returns the length of the string arg

• string substring(string arg1, number arg2, optional number arg3) //return substring of arg1

• string substring-before(string arg1, arg2) //

• string substring-after(string arg1, arg2) //

• string translate(string arg1, arg2, arg 3) //

Page 15: XPath

Functions and location paths are orthogonal

Page 16: XPath

• /child::Contacts/child::Contact[@id=3]/child::phone

• /Contacts/Contact[@id=3]/phone

Page 18: XPath