I have 4,000 xml files in folders a, b, c, and d Each folder contains 1000 files each. All folders are in main folder called library I need to check if the xml files are well formed using
xmllint --noout 100.xml"
command or may be with something better. Now incase of error, log the file name plus folder name in a log file.
log "library/a/100.xml"
Below is the Pseudo code. I need to build the script to run in shell script or something faster
#program check xml format
#!/bin/bash
echo Please, get ready to process
for i in $(cat "/home/thrinity/library/);
do
xmllint --noout "$i" ;
if error
#log filefolder & file name
print error to errorlog.txt
else
end do
I am looking for error where a tag is missing.. something like.. 038339 here the invoice closing tag is missing or any way I can capture this
For those who might be intrested. The code below worked for me in Ubuntu 14.04 machine
find /YourMainFolder -name '*.xml' -print | xargs -I "{}" sh -c 'File="{}";xmllint --noout "${File}" || readlink -f {} >> errorlog.txt
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire