1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
| <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> </head> <body> <ul> <li id="l1" class="c1">四川</li> <li id="l2">重庆</li> <li>贵州</li> </ul> <ul> <li>成都</li> <li>湖南</li> <li>白净</li> </ul>
</body> </html>
查找ul下面的li
xpath ://body/ul/li
查找 li下面所有有id属性的li标签,text()获取标签中内容 xpath ://ul/li[@id]/text()
找到标签为li的标签 xpath ://ul/li[@id="l1"]
查找到id 为l1的li标签的class的属性值 //ul/li[@id="l1"]/@clas
|