答案 0 :(得分:1)
我可能会晚一点,但是以下XQuery可能会完成您希望的事情,它将返回每个不包含特定元素的XML文件的路径:
let $path := "."
for $file in file:list( $path, true(), '*.xml')
let $path := $path || "/" || $file
where not(
exists(fetch:xml($path)/foo/bar[text() = "Text"])
)
return $path
如果您只对特定的XML文件包含或不包含特定元素感兴趣,则以下查询可能会有用:
declare variable $path := "/Users/michael/Code/foo";
every $doc in file:list($path, true(), '*.xml') (: returns a sequence of file-names :)
=> for-each(concat($path,"/", ?)) (: returns a sequence of full paths to each file :)
=> for-each(fetch:xml#1) (: returns a sequence of documents :)
satisfies exists(
$doc/*/*[text() = "Text"]
)
希望这会有所帮助;-)