2017-02-12 41 views
-2
<div id="content-body-14269002-17290547"> 
<p>...</p> 
<p>...</p> 
<p>...</p> 
<p>...</p> 
<p>...</p> 
</div> 

我需要在id = "content-body*"使用Xpath包含ID?

每一頁上的內容,身體的變化,選擇一切可以需要使用通配符

回答

2

大概xpath search for divs where the id contains specific text重複

不管怎麼說,

對於IDS

//div[contains(@id,"content-body")]//p #to Select all Paragraphs 

//div[contains(@id,"content-body")]//p//text() # To Select all text in Paragraphs 

上課

//*[contains(@class,"content-body")//p 
//div[contains(@class,"content-body")]//p//text() 

對於Class在類

//*[contains(@class,"content-body") and contains(@class,"another-sub-content-body")]//p//text() 

希望它幫助!

0
//div[contains(@id, "content-body")] 

這意味着content-bodycontent-body-14269002-17290547

通常情況下,這將作品。

更好:

//div[starts-with(@id, "content-body")] 

這意味着id屬性的值開始content-body

+1

您錯過了結束回合支架 – Connum