【发布时间】:2011-09-17 11:05:24
【问题描述】:
考虑this example from w3schools:
<?xml version="1.0" encoding="ISO-8859-1"?>
<bookstore>
<book category="COOKING">
<title lang="en">Everyday Italian</title>
<author>Giada De Laurentiis</author>
<year>2005</year>
<price>30.00</price>
</book>
<book category="CHILDREN">
<title lang="en">Harry Potter</title>
<author>J K. Rowling</author>
<year>2005</year>
<price>29.99</price>
</book>
<book category="WEB">
<title lang="en">XQuery Kick Start</title>
<author>James McGovern</author>
<author>Per Bothner</author>
<author>Kurt Cagle</author>
<author>James Linn</author>
<author>Vaidyanathan Nagarajan</author>
<year>2003</year>
<price>49.99</price>
</book>
<book category="WEB">
<title lang="en">Learning XML</title>
<author>Erik T. Ray</author>
<year>2003</year>
<price>39.95</price>
</book>
</bookstore>
xmlstarlet sel -t -v "//@category" 书籍.xml
只返回烹饪。如何获取所有名为 category 的属性?
奖励问题:如何在不使用编辑器或程序打开 XML 文件的情况下评估 XPath 查询(我想要一个快速工具)。问题是将大文件加载到内存中会使编辑器崩溃。不要告诉我 eXist 是我最好的选择吗?
【问题讨论】:
标签: xpath command-line-interface exist-db xmlstarlet