问题描述
我正在尝试查看libxml如何实现XPath支持,因此使用xmllint进行测试对我来说很有意义.但是,明显的选项--pattern有点晦涩,我最终使用了以下内容:
I'm trying to see how libxml implements XPath support, so it made sense to me to test using xmllint. However, the obvious option, --pattern, is somewhat obscure, and I ended up using something like the following:
test.xml: <foo><bar/><bar/></foo>
> xmllint --shell test.xml
/ > dir /foo
ELEMENT foo
/ > dir /foo/*
ELEMENT bar
ELEMENT bar
这似乎可行,这很好,但是我仍然很好奇. xmllint的--pattern选项有什么用途,如何工作?
This seems to work, and that's great, but I'm still curious. What is xmllint's --pattern option for, and how does it work?
提供完整积分的示例. =)
Provide an example for full credit. =)
推荐答案
提示在单词可以与解析器的阅读器接口一起使用"中:xmllint仅在传递--stream选项时使用阅读器接口:
The hint is in the words "which can be used with the reader interface to the parser": xmllint only uses the reader interface when passed the --stream option:
$ xmllint --stream --pattern /foo/bar test.xml
Node /foo/bar[1] matches pattern /foo/bar
Node /foo/bar matches pattern /foo/bar
这篇关于如何使用xmllint的--pattern选项?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!