mehdix_
mehdix_

Reputation: 479

XPATH: selecting text node with an embedded node

having the following XML code:

<div class="content">
<ul>
<li>
<b>Item model number:</b>
   FCC5302Q-2
</li>
</ul>

I used this xpath expression to select the li node text:

//*[contains(@class, "content")]//li[b/text()="item model number"]/text()

And for some reason it fails to pick the text of the li element. Where am I going wrong with this?

Upvotes: 0

Views: 494

Answers (2)

bit
bit

Reputation: 4487

  1. Use single quotes
  2. Match cases
  3. Watch out for the brackets you use..

Try this XPath..

//*[contains(@class, 'content')]//li/b[text()='Item model number:']/text()

Upvotes: 1

John Kugelman
John Kugelman

Reputation: 362007

Make sure you write the <b> element text verbatim, including case.

//*[contains(@class, "content")]//li[b/text()="Item model number:"]/text()

Upvotes: 0

Related Questions