开发者

Is there a convenient way to turn XML into a suds.sax.element.Element instance?

开发者 https://www.devze.com 2023-01-31 15:25 出处:网络
I am using suds to make some RPC calls that require arguments like suds.sax.element.Element(\'html\').append(Element(\'body\'))

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号