Created
August 24, 2013 07:21
-
-
Save klb3713/6326630 to your computer and use it in GitHub Desktop.
lxml: 使用xsd验证xml文件
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
__author__ = 'klb3713' | |
from lxml import etree | |
xsdfile = etree.parse("./test.xsd") | |
xmlschema = etree.XMLSchema(xsdfile) | |
xmldoc = etree.parse("./test.xml") | |
print xmlschema.validate(xmldoc) | |
xmlschema.assert_(xmldoc) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment