XPath - trim and starts-with together (cut of whitespaces)
I have XML like this:开发者_如何学JAVA
<div class="errorMessage">
<ul>
<li>
<a href="...">
ABC - efg
</a>
<a href="...">
HIJ - klm
</a>
</li>
</ul>
</div>
How do I select link's text which starts with "ABC"? I need to trim the "text()" of "a" and apply "starts-with()" on it. I have something like this, but it doesn't work:
//div[@class='errorMessage']/.//a[starts-with(normalize-space(./text())),'ABC')]/text()
This ought to work:
//div[@class='errorMessage']//a[starts-with(normalize-space(.), 'ABC')]/text()
精彩评论