Created by Jerry Wang on Jun 26, 2014
测试使用的xml:
<catalog>
<cd>
<title>Empire Burlesque</title>
<artist>Bob Dylan</artist>
<country>USA</country>
<company>Columbia</company>
<price>10.90</price>
<year>1985</year>
</cd>
<cd>
<title>Hide your heart</title>
<artist>Bonnie Tyler</artist>
<country>UK</country>
<company>CBS Records</company>
<price>9.90</price>
<year>1988</year>
</cd>
</catalog>
如果注释掉apply_templates:
输出:
试图只选择title node:
没有得到预期的效果:
必须先匹配整个document,再匹配某个子节点:
输出只包含这两个子节点:
将match换成xpath也能工作:match="/catalog/cd"
或者match=“cd[parent::catalog]”。
直接match title node:
输出: