【问题标题】:XPATH and XMLStarletXPATH 和 XMLStarlet
【发布时间】:2016-05-26 14:34:37
【问题描述】:

我现在正在努力完成以下任务。我正在尝试使用 XMLStarlet 删除空的 XML 条目。

我尝试的是使用这个 XPATH:

//*[not(./*) and (not(./text()) or normalize-space(./text())='')]

我已经在http://www.freeformatter.com/xpath-tester.html 上对其进行了测试,它按预期工作。与 XMLStarlet 配合使用不起作用:

xmlstarlet ed -d '//*[not(./*) and (not(./text()) or normalize-space(./text())='')]'

这可能是什么原因?

【问题讨论】:

  • 什么地方没用?请提供示例 XML 进行测试...

标签: xpath xmlstarlet


【解决方案1】:

尝试在双引号中使用引号,反之亦然。

你的例子:

xmlstarlet ed -d '//*[not(./*) and (not(./text()) or normalize-space(./text())="")]'

xmlstarlet ed -d "//*[not(./*) and (not(./text()) or normalize-space(./text())='')]"

【讨论】:

  • 嗨,我已经检查过了,它按预期工作。非常感谢。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-05-31
  • 1970-01-01
  • 2012-09-20
  • 1970-01-01
相关资源
最近更新 更多