开发者

PHP XPATH Mind Melt

开发者 https://www.devze.com 2023-01-10 07:37 出处:网络
Really simple xpath call but I am having a mindblock. My XML file looks like this <?xml version=\"1.0\"?>

Really simple xpath call but I am having a mindblock.

My XML file looks like this

<?xml version="1.0"?>
<books>
    <book>bob</book>
</books>

I want do an XPATH call to find the node with the value of bob whcih seems to work but whenever I put a no exsistent book value in, it still return开发者_JAVA技巧s the node of bob. My XPATH Query is

/books/book[.='bob2']

Is my XPATH wrong? Really having a mad brain block!

Steve


you can just select /books/book and test for equality to "bob2". alternatively, you can use the text() function, but with some caveats.

0

精彩评论

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