linux - Grep an XML file for certain patterns -
I have a large XML file that has thousands of elements the same elements:
& lt ; RootElem & gt; & Lt; Filoj buzz = "true" & gt; 234 & lt; / Fizz & gt; & Lt; Fizz buzz = "false" & gt; 384 & lt; / Fizz & gt; & Lt; Philos buzz = "true" & gt; & Lt; / Fizz & gt; & Lt; Filoz buzz = "true"> 39494 I will run a grep which will be & lt; Fizz & gt; Prints prints, which do not contain text / body data (the number between the opening and closing tags). In the example above, grep 3 and 5th & lt; Fizz & gt; will generate 2 lines for elements, which will not contain numeric data, the file name is phizze_20.xml . I tried to run the following, but it did not work: -
grep fizzes_20.xml "> -
Grep fizzes_20.xml "/> Any thoughts? thank you in advanced!
The xmllint command can be used to implement xpath expression tests for empty nodes:
$ xmllint --xpath "// fizz [not (text ())]" data.xml & lt; Fizz buzz = "true" /> & Lt; Fizz / & gt; Compiled with update $ xmllint --version xmllint: 20901 threads: threads tree output push reader pattern author SAXv1 FTP HTTP DTDValid HTML Legacy C14N List XPath XPointer XInclude Iconv ISO8859X Unicode Regexps Automata Expr Schemas Schematron Module Debug Zlib Lzma
Comments
Post a Comment