このコマンドの出力を os.system と os.popen の両方で取得しようとしましたが、うまくいきませんでした。コマンドがコンソールに出力をスローするのを止め、代わりに出力をデータ構造またはファイルにキャプチャして、さらにチェックして処理したいと考えています。xmllint と呼ばれる単純なツールを使用しています。私は試した
1. p = os.popen('xmllint --noout --relaxng /home/xxxxx_id/folder_xx/xxxx/xxx/rngfile.rng /home/xxxxx_id/folder_xx/xxxx/xxx/xxx/the_xmlfile_that_needstobe_validated.xml')
2. os.system('xmllint --noout --dtdvalid ' + path to the xml + '> xmloutput')
どちらも失敗したようで、ファイルまたはデータ構造にコピーする代わりに、コンソールに出力を表示します。100 以上の xml を検証する必要があり、各 outout を個別にチェックできるはずです。
ヘルプ?
以下で解決:
os.system('xmllint --noout --dtdvalid ' + path to the xml + '> xmloutput 2>&1')