Quantcast
Channel: Identify empty xml files? - Unix & Linux Stack Exchange
Viewing all articles
Browse latest Browse all 3

Answer by Gilles Quenot for Identify empty xml files?

$
0
0

Try this using with a expression :

#!/bin/sh

for xml in *.xml; do
    bool=$(xmllint --xpath 'count(//*)=1 and string-length(//*[1])=1' "$xml")
    if [ $bool = true ]; then
        echo "$xml" >> xml_list_files
    fi
done

cat xml_list_files

The expression test that the file have only one node without any text content. In this case, the command return true


Viewing all articles
Browse latest Browse all 3

Trending Articles