如何使用XPath根据其内容选择
XML节点?
如果我有以下xml,我想选择包含Ritchie的< author> -node来获取作者的全名:
<books> <book isbn='0131103628'> <title>The C Programming Language</title> <authors> <author>Ritchie,Dennis M.</author> <author>Kernighan,Brian W.</author> </authors> </book> <book isbn='1590593898'> <title>Joel on Software</title> <authors> <author>Spolsky,Joel</author> </authors> </book> </books>
/books/book/authors/author[contains(.,'Ritchie')]
要么
//author[contains(.,'Ritchie')]