问题标签 [xmlstarlet]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
2 回答
1453 浏览

xmlstarlet - 使用 xmlstarlet 提取多个值

如何从所有元素中提取“失败”并将它们相加?

0 投票
1 回答
274 浏览

xsl-fo - 使用 xmlstarlet 更新 xsl 文件

我是

使用 xmlstarlet 将“xsl:stylesheet/xsl:template/filter/filter-class”的值更改为“Hello”给出以下命令,但它给出了错误:-

我在哪里错了?

0 投票
1 回答
280 浏览

xmlstarlet - 使用 xmlstarlet 提取数据

我有以下格式的 xml 文件,并且想在元素 /CONFIG/NIC/MGMT=1 时提取元素 IP、NETWORK、NETMASK、GATEWAY 和 VLANID 中的值。有人可以指出我正确的方向...任何帮助将不胜感激..谢谢

0 投票
1 回答
5540 浏览

xml - Xmlstarlet 在更新 xml 时使用 --inplace 选项

我正在尝试使用 --inplace 全局选项更新一个 xml 标签,如下所示

以上是给我错误

我试图修改的 xml 如下所示:-

0 投票
1 回答
156 浏览

xml - xmlstarlet - 排序交替的标记值对

有了这个 XML

我想要 xmlstarlet 的这个输出:

但是使用这个命令:

我得到:

0 投票
1 回答
1977 浏览

suppress-warnings - 如何忽略 XMLStarlet 中的空选择?

我有一个使用XMLStarlet执行许多 XML 编辑操作的脚本。例如,foo如果存在任何节点,它会删除所有节点:

(除了在我的脚本中,元素的名称不是foo)。

当没有foo节点存在时,将打印以下消息:

foo但是,如果输入文档中不存在任何节点,则没有任何问题。所以对于这个特定的操作,我确实想避免这个特定的警告,而我一般不想禁用这样的警告。

我怎样才能做到这一点?

0 投票
1 回答
460 浏览

xpath - xmlstarlet 将一个元素添加到文件中

我有数百个 xml 文件要处理 - 有些有特定的所需标签,有些没有。如果我只是将标签添加到所有文件,那么一些文件会得到 2 个标签(这并不奇怪!)。如何在没有笨拙的 grep 的情况下在 xmlstarlet 中选择要处理的文件?例如:

我在一些文件中有这个:...

我想要这个(但有些文件已经有了):...

例如,这可行,但我希望我可以在没有 grep 的情况下完全在 xmlstarlet 中完成它:

我让自己陷入了一些 XPATH 异国情调中,比如:

...但它没有做我所希望的...

0 投票
1 回答
1334 浏览

xml - xmlstarlet:如何选择项目来构建哈希

我想xmlstarlet从以下 XML 文件 (list.xml) 中提取(使用)

readableName给定的值name。在上面的示例中,这将Scan1用于查询b486f8d9.

在一个非常相似的问题上找到了一个很好的答案,但是查询是在另一种类型的元素上,然后尝试了

但这不起作用(空输出)

您能帮我为我的案例构建适当的查询吗?因为我最终想在 bash 中构建一个哈希(键name和值readableNametimestamp)也许有一种更聪明的方法来做到这一点,而不是按照我打算的方式解析文件(=首先获取names 的列表,然后查询他们每个人的价值)?

谢谢!

0 投票
3 回答
602 浏览

xml - Approaches for performing a "Grep -f" style query on XML data?

I saw several great command-line XML manipulation tools in this discussion, and I'm exploring new ways to extract data from XML files through scripting instead of compiled programs. I'm currently trying out xmlstarlet, but I'm not restricted to using this tool.

I have an XML data file that has tens of thousands of elements. I'd like to extract a subset of those elements based on a list of search terms, and then pipe or otherwise route those elements into some downstream scripts and transforms. The search terms are simple strings--there's no need for regular expressions. If I was doing this with grep on a regular text file, I would probably do something simple like:

I've been looking through the documentation for tools like xmlstarlet on ways that I could achieve this, and the closest thing I can come up with is this ugly attempt that uses a temporary file. (Note, I am using Windows):

Needless to say, this is really ugly.

I suppose that one possibility is to modify the for loop to pass a giant list of -c XPath queries to xmlstarlet all in one shot, but that also seems unnecessarily messy, and I think that I would still be stuck with using the tempOutput.xml file.

Is there a more elegant way to do this? Or is a temporary file really my best approach?

0 投票
1 回答
856 浏览

xml - XMLStarlet 和 RSS

我似乎无法通过 xmlstarlet 获得这个基本的 xslt 查询。

我确定我遗漏了一些明显的东西,但是对于我的生活,我无法弄清楚这种语法,所以请有人照亮我。

XML Starlet 命令:

sss.rdf:

我想要的输出: