Xpath查找Windows的文件? xml解析器以在Windows中查找文件 [英] Xpath find files for windows? xml parser to find files in windows

查看:196
本文介绍了Xpath查找Windows的文件? xml解析器以在Windows中查找文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我们有1500个xhtml页面,比如说/myfolder的100个子文件夹.我想找到邪恶的星座

So we have 1500 xhtml pages in lets say 100 subfolders of /myfolder. I want to find evil constellations of

<goodTag>
 ....
 <evilTag/>
 ....
 <evilTag/>
 ....
</goodTag>

在我当前的情况下,仅允许

In my current case, it is only allowed to have

<goodTag>
....
<evilTag/>
...
</goodTag>

,而不是2个邪恶的标签包含在一个好的标签中.不过,这只是一个例子.有时我必须搜索类似

and not 2 evil Tags within a good Tag. This is just an example though. Sometimes I must search for something like

<outter>
....
<someTag someAttribute="iDoEvil" />
...
</outter>

我已经浏览了一段时间,找不到能够帮助我完成此任务的工具. Windows中提供哪些免费的软件/开源解决方案?

I've been browsing for a while now and could not find a tool which would help me to do so. What free ware / open source solutions are availble in windows?

xhtml文件是什么样的?基本上,它们是为JSF创建的网页.我们使用自己的标签并不断对其进行更改,因此,必须密切注意尚未想到的星座问题

What are the xhtml files like? basically they are web pages created for JSF. We use our own tags and keep doing changes to them and thus, have to keep a good eye on bad constellation who haven't been thought of

我基本上是在问,因为我最终还是用正则表达式来做这件事,这使周围的人发疯了.

I'm basically asking because I finally ended up doing it with regex, which makes people around here going nuts.

推荐答案

这是bash解决方案:

  • 找到当前目录中的所有xml文件
  • 列出所有包含<someTag someAttribute="iDoEvil" />
  • 的xml文件
  • find all xml files in current directory
  • list all xml files which contain <someTag someAttribute="iDoEvil" />
for i in `find . -name '*.xml'`
do
    if xmlstarlet sel -H -t -m '//someTag[@someAttribute="iDoEvil"]' -v @someAttribute "$i" >/dev/null
    then
        echo "$i"
    fi
done

注意:我没有尝试在Windows中编写DOS脚本,但是想法是相同的.
您可以在此处下载 xmlstarlet(Windows版本).

Note: I haven't try to write a DOS script in Windows, but the idea is the same.
You can download xmlstarlet(windows version) here.

这篇关于Xpath查找Windows的文件? xml解析器以在Windows中查找文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆