Skip to content

Instantly share code, notes, and snippets.

@molotovbliss
Last active January 25, 2017 16:23
Show Gist options
  • Save molotovbliss/4b9f4f89a3fa6c2264f8015cbb7d1569 to your computer and use it in GitHub Desktop.
Save molotovbliss/4b9f4f89a3fa6c2264f8015cbb7d1569 to your computer and use it in GitHub Desktop.
Batch over current working directory using XMLlint to ensure well formed XML document
# Batch over current working directory using XMLlint to ensure well formed XML document. --schema for.xsd
find . -name "*.xml" -type f | xargs xmllint --noout
# Batch over current working directory using XMLlint and repair malformed XML docs
find . -name "*.xml" -type f | xmllint --format --recover --noout --output
# Single file check:
xmllint --noout <file.xml>
# Fix malformed XML in PHP
$xml = new DomDocument();
$xml->recover=true;
$xml->loadXML('<root><tag>hello world</root>');
echo $xml->saveXML();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment