1. In XPath , indexing does not start with zero.
2. '/' absolute path and start with root node where as '//' is relative path start with curretn node.
3. '.' means current node where as '..' is parent node.
4. '*' means all child node from current node or path.
5. While writing xpath we can not leave /by pass any element.
6. <book>
<title lang= "en"> Harry Poter</title>
</book>
lang = "en" (attribute node) @
//div[@id = 'file1'] // id is attribute for div.
7. We can select some row based on attribute.
.//*[@id='container']/child::div[1]/div[2]/div[@id = 'file2']/table/tbody/tr/td[3]/div/attribute::title
Means each row which have div tag under that have attribute name title.
Example:
<div class="l lc d1" title="Diff 1: Change 4 lines (1 - 4, first file) to 4 lines (1 - 4, second file)">
<div class="l lc d1" title="Diff 1: Change 4 lines (1 - 4, first file) to 4 lines (1 - 4, second file)">
<div class="l lc d1" title="Diff 1: Change 4 lines (1 - 4, first file) to 4 lines (1 - 4, second file)">
<div class="l lc d1" title="Diff 1: Change 4 lines (1 - 4, first file) to 4 lines (1 - 4, second file)">
8. We can access last to one element usign last().
<tr>
<td class="diffBar" style="">
<td class="nums">
<td class="content">
Above example we can access "nums" and "Content" using last-1 , last-2 fucntion.
.//*[@id='container']/child::div[1]/div[2]/div[@id = 'file2']/table/tbody/tr/td[last()-2]
.//*[@id='container']/child::div[1]/div[1]/div[@id = 'file1']
.//*[@id='container']/child::div[1]/div[2]/div[@id = 'file2']/table/tbody/tr/td[3]/div/attribute::title
2. '/' absolute path and start with root node where as '//' is relative path start with curretn node.
3. '.' means current node where as '..' is parent node.
4. '*' means all child node from current node or path.
5. While writing xpath we can not leave /by pass any element.
6. <book>
<title lang= "en"> Harry Poter</title>
</book>
lang = "en" (attribute node) @
//div[@id = 'file1'] // id is attribute for div.
7. We can select some row based on attribute.
.//*[@id='container']/child::div[1]/div[2]/div[@id = 'file2']/table/tbody/tr/td[3]/div/attribute::title
Means each row which have div tag under that have attribute name title.
Example:
<div class="l lc d1" title="Diff 1: Change 4 lines (1 - 4, first file) to 4 lines (1 - 4, second file)">
<div class="l lc d1" title="Diff 1: Change 4 lines (1 - 4, first file) to 4 lines (1 - 4, second file)">
<div class="l lc d1" title="Diff 1: Change 4 lines (1 - 4, first file) to 4 lines (1 - 4, second file)">
<div class="l lc d1" title="Diff 1: Change 4 lines (1 - 4, first file) to 4 lines (1 - 4, second file)">
8. We can access last to one element usign last().
<tr>
<td class="diffBar" style="">
<td class="nums">
<td class="content">
Above example we can access "nums" and "Content" using last-1 , last-2 fucntion.
.//*[@id='container']/child::div[1]/div[2]/div[@id = 'file2']/table/tbody/tr/td[last()-2]
.//*[@id='container']/child::div[1]/div[1]/div[@id = 'file1']
.//*[@id='container']/child::div[1]/div[2]/div[@id = 'file2']/table/tbody/tr/td[3]/div/attribute::title
No comments:
Post a Comment