开发者

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()

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜