如何完全从原始 XML 创建twisted.words.xish.domish.Element
令我惊讶的是 XML 基本对象 (twisted.words.xish.domish.Element) 无法完全从 XML 字符串创建。最相似的方法是:
msg = "<iq to='[email protected]' id='id123' type='get'> \
<query xmlns='http://juick.com/query#messages' mid='123456'/> \
</iq>"
iq = domish.Element(('',''))
iq.addRawXml(msg)
但它生成:
iq.toXml()
u"<><iq to='[email protected]' id='id123' type='get'> <query xmlns='http://juick.com/query#messages' mid='123456'/> </iq></>"
除了编写我自己的 IElement 实现之外,还有什么方法可以使用原始 XML?
I was surprised that XML basic object (twisted.words.xish.domish.Element) could not be created entirely from XML string. The most alike way is:
msg = "<iq to='[email protected]' id='id123' type='get'> \
<query xmlns='http://juick.com/query#messages' mid='123456'/> \
</iq>"
iq = domish.Element(('',''))
iq.addRawXml(msg)
But it generates:
iq.toXml()
u"<><iq to='[email protected]' id='id123' type='get'> <query xmlns='http://juick.com/query#messages' mid='123456'/> </iq></>"
Is there any way to use raw XML except writing my own IElement implementation?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这就是我用于片段的内容,改编自网络上某处找到的内容。
This is what I use for fragments, adapted from something found on the web somewhere.