Sunday, 13 July 2014

How can I make Python's ElementTree enforce XML schema?



Suppose I wish to parse an XML document, and its schema dictates that a given element can only occur once.


How do I make sure that an exception gets raised if the element occurs twice or more?


Or, if the schema says that a given element's value should be an integer, and the value is "turkey sandwich", how do I make the parser crash and burn like it's supposed to?


Can ElementTree do this? Can anything do this? Does this question even make sense?


No comments:

Post a Comment