XPath
is defined as XML path. As XPath is a query language which is based on
the tree representation of the XML document, it provides the ability to
navigate around the XML tree and locate individual elements, attributes
or any other node of the XML document. XML and HTML are like siblings.
They have a very similar structure and as a result XPath can be used to
query HTML document too.
Syntax for XPath:
The syntax for XPath is very simple and easy to understand. Standard syntax for constructing XPath is given below:
XPath = //tag[@attribute = 'value']// : used to select the desired node.
tag : tag of that particular node.
@ : used to select attribute.
attribute : name of the attribute.
value : value of the attribute
For example:
For example:
//li[@id = 'ogbkddg:4']Here,
- //li selects all 'li' node
- @id = 'ogbkddg:4' selects the attribute which has 'ogbkddg:4' as attribute id value.
No comments:
Post a Comment