本文整理汇总了Python中suds.sax.element.Element.prune方法的典型用法代码示例。如果您正苦于以下问题:Python Element.prune方法的具体用法?Python Element.prune怎么用?Python Element.prune使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类suds.sax.element.Element
的用法示例。
在下文中一共展示了Element.prune方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: basic
# 需要导入模块: from suds.sax.element import Element [as 别名]
# 或者: from suds.sax.element.Element import prune [as 别名]
def basic():
xml = "<a>Me && <b>my</b> shadow's <i>dog</i> love to 'play' and sing "la,la,la";</a>"
p = Parser()
d = p.parse(string=xml)
a = d.root()
print 'A(parsed)=\n%s' % a
assert str(a) == xml
b = Element('a')
b.setText('Me && <b>my</b> shadow\'s <i>dog</i> love to \'play\' and sing "la,la,la";')
print 'B(encoded)=\n%s' % b
assert str(b) == xml
print 'A(text-decoded)=\n%s' % a.getText()
print 'B(text-decoded)=\n%s' % b.getText()
assert a.getText() == b.getText()
print 'test pruning'
j = Element('A')
j.set('n', 1)
j.append(Element('B'))
print j
j.prune()
print j
示例2: Ortel
# 需要导入模块: from suds.sax.element import Element [as 别名]
# 或者: from suds.sax.element.Element import prune [as 别名]
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
# written by: Jeff Ortel ( [email protected] )
#
# sax encoding/decoding test.
#
from suds.sax.element import Element
from suds.sax.parser import Parser
xml = "<a>Me && <b>my</b> shadow's <i>dog</i> love to 'play' and sing "la,la,la";</a>"
p = Parser()
d = p.parse(string=xml)
a = d.root()
print 'A(parsed)=\n%s' % a
assert str(a) == xml
b = Element('a')
b.setText('Me && <b>my</b> shadow\'s <i>dog</i> love to \'play\' and sing "la,la,la";')
print 'B(encoded)=\n%s' % b
assert str(b) == xml
print 'A(text-decoded)=\n%s' % a.getText()
print 'B(text-decoded)=\n%s' % b.getText()
assert a.getText() == b.getText()
print 'test pruning'
j = Element('A')
j.set('n', 1)
j.append(Element('B'))
print j
j.prune()
print j