美文网首页
python对xml进行schema检查

python对xml进行schema检查

作者: f9f73935e28c | 来源:发表于2016-11-16 15:23 被阅读0次
#-*- coding:utf-8 -*-
"""
usage:
    python xml_schema_check.py schema_file data_file
"""
from lxml import etree
import sys
schema_file = sys.argv[1]
data_file = sys.argv[2]

schema_doc = etree.parse(schema_file)
schema = etree.XMLSchema(schema_doc)

data = etree.parse(data_file)
print schema.validate(data)
print schema.error_log 

相关文章

网友评论

      本文标题:python对xml进行schema检查

      本文链接:https://www.haomeiwen.com/subject/pujrpttx.html