如何打印所有 xml 文件中标题属性的所有属性值
不知有人知道吗 我可以使用什么命令或 bash 脚本代码 打印出我所有 xml 文件(当前目录中)中标题属性的所有值。
我正在使用 cygwin 并且文件名包含空格。
( 我一直在谷歌上搜索,有很多关于下载其他实用程序的建议。如果我能避免这种情况,那对我来说是有好处的。例如,我安装了 sgrep,然后收到此错误: sh: m4: 命令未找到 系统(“m4 -s”)返回非零退出状态(32512)。 预处理器返回空文件 )
如果有一个 Xpath 程序可以免费下载到 Windows 并像独立搜索程序一样使用,那就太好了 =)
提前感谢您的帮助 /T
I wonder if anybode knows
what command or bash-script-code I can use
to print out all the values of the title attributes in all my xml files (in current directory).
I'm using cygwin and have file names containing white spaces.
(
I've been googling around and there are a lot of suggestions on downloading other utilities. If I can avoid that it would be good for me. For example I installed sgrep and then got this error: sh: m4: command not found
system("m4 -s") returned non zero exit status (32512).
Preprocessor returned empty file
)
If there is an Xpath program that is free to download to windows and use like a stand alone search program, that would be great too =)
Thanks in advance for helping out
/ T
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果标签和标题属性都在同一行,但标签的不同实例之间存在换行,则以下内容可能适合您。例如
,然后您可以执行类似以下操作,以查找包含
Title
属性的感兴趣标签:或者,您应该能够使用
find
和xargs
:现在您知道您拥有正确的标签及其相应的 Title 属性,您只需要 Title 属性,因此您可以使用
grep
的-o 选项仅输出与正则表达式匹配的数据,然后剪切以提取标题的值:
If the tag and the title attribute are all on the same line, but there are line feeds between the different instances of your tag, the following could work for you. For example
Then you could do something like the following in order to find the tags of interest that contain a
Title
attribute:Alternatively, you should be able to use
find
andxargs
:Now that you know you have the correct tag and its corresponding Title attribute, you just want the Title attribute, so you can use
grep
's-o
option to output only the data matching the regular expression followed by cut to extract the value of the Title:你需要在 cigwin 中安装预处理器“m4”,这将使你的 sgrep 工作
我遇到了同样的问题,安装“m4”解决了我在 cygwin 中的问题
you need to install the preprocessor "m4" in cigwin that will make your sgrep work
I faced same problem installing "m4" resolved my issue in cygwin
你安装了 xml_grep 吗?它是免费的,并且是我安装的 centOS 的标准配置。它可以采用 xpath 表达式并打印结果。
Do you have xml_grep installed? It is free and came standard on my install of centOS here. It can take an xpath expression and print the results.