I am using suds to make some RPC calls that require arguments like
suds.sax.element.Element('html').append(Element('body'))
This is cumbersome especially if the needed XML is constant. Is there a convenient开发者_如何学JAVA way to just get the Element by parsing text, for example
fromstring('<html><body></body></html>')
?
The answer is YES. You can use suds.sax.parser.Parser
(btw, why is this not on the SUDS docs directly??)
The answer is NO.
There's no other simpler way to deal with the XML creation with SAX.
I believe that's because the nature of SAX in creating XML (read this).
Why was choosen SAX and not a DOM API ?
The suds.sax module was written because elementtree and other python XML packages either have a DOM API which is very unfriendly or (in the case of elementtree) do not deal with namespaces and especially prefixes sufficiently.
精彩评论