本文整理汇总了Python中pysimplesoap.simplexml.SimpleXMLElement.add_child方法的典型用法代码示例。如果您正苦于以下问题:Python SimpleXMLElement.add_child方法的具体用法?Python SimpleXMLElement.add_child怎么用?Python SimpleXMLElement.add_child使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pysimplesoap.simplexml.SimpleXMLElement
的用法示例。
在下文中一共展示了SimpleXMLElement.add_child方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_marshall_cdata
# 需要导入模块: from pysimplesoap.simplexml import SimpleXMLElement [as 别名]
# 或者: from pysimplesoap.simplexml.SimpleXMLElement import add_child [as 别名]
def test_marshall_cdata(self):
span = SimpleXMLElement('<span/>')
cdata = CDATASection()
cdata.data = 'python'
span.add_child('a', cdata)
xml = '<?xml version="1.0" encoding="UTF-8"?><span><a><![CDATA[python]]></a></span>'
self.eq(span.as_xml(), xml if PY2 else xml.encode('utf-8'))
示例2: makeNRPSrequest
# 需要导入模块: from pysimplesoap.simplexml import SimpleXMLElement [as 别名]
# 或者: from pysimplesoap.simplexml.SimpleXMLElement import add_child [as 别名]
def makeNRPSrequest(seqs):
root = SimpleXMLElement("<predict></predict>",prefix="ws",namespace="http://ws.NRPSpredictor2.roettig.org/")
root.add_child("request",ns=True)
print root.as_xml(pretty=True)
arg0_node = root.children()[0]
idx = 1
for seq in seqs:
seqs_node = arg0_node.add_child("sequence",ns=True)
seqs_node.add_child("id","%d"%idx,ns=True)
seqs_node.add_child("kingdom","0",ns=True)
seqs_node.add_child("seqString",seq,ns=True)
seqs_node.add_child("sequenceType","0",ns=True)
idx+=1
print root.as_xml(pretty=True)
return root
示例3: initializeReg
# 需要导入模块: from pysimplesoap.simplexml import SimpleXMLElement [as 别名]
# 或者: from pysimplesoap.simplexml.SimpleXMLElement import add_child [as 别名]
def initializeReg(apitoken):
client = SoapClient(
wsdl = "https://www.regonline.com/api/default.asmx?WSDL"
, trace = False)
header = SimpleXMLElement("<Headers/>")
MakeHeader = header.add_child("TokenHeader")
MakeHeader.add_attribute('xmlns','http://www.regonline.com/api')
MakeHeader.marshall('APIToken', apitoken)
client['TokenHeader']=MakeHeader
return client
示例4: test_basic
# 需要导入模块: from pysimplesoap.simplexml import SimpleXMLElement [as 别名]
# 或者: from pysimplesoap.simplexml.SimpleXMLElement import add_child [as 别名]
def test_basic(self):
span = SimpleXMLElement('<span><a href="python.org.ar">pyar</a><prueba><i>1</i><float>1.5</float></prueba></span>')
span1 = SimpleXMLElement('<span><a href="google.com">google</a><a>yahoo</a><a>hotmail</a></span>')
self.eq([str(a) for a in span1.a()], ['google', 'yahoo', 'hotmail'])
span1.add_child('a', 'altavista')
span1.b = "ex msn"
d = {'href': 'http://www.bing.com/', 'alt': 'Bing'}
span1.b[:] = d
self.eq(sorted([(k, v) for k, v in span1.b[:]]), sorted(d.items()))
xml = '<?xml version="1.0" encoding="UTF-8"?><span><a href="google.com">google</a><a>yahoo</a><a>hotmail</a><a>altavista</a><b alt="Bing" href="http://www.bing.com/">ex msn</b></span>'
self.eq(span1.as_xml(), xml)
self.assertTrue('b' in span1)
span.import_node(span1)
xml = '<?xml version="1.0" encoding="UTF-8"?><span><a href="python.org.ar">pyar</a><prueba><i>1</i><float>1.5</float></prueba><span><a href="google.com">google</a><a>yahoo</a><a>hotmail</a><a>altavista</a><b alt="Bing" href="http://www.bing.com/">ex msn</b></span></span>'
self.eq(span.as_xml(), xml)
types = {'when': datetime.datetime}
when = datetime.datetime.now()
dt = SimpleXMLElement('<when>%s</when>' % when.isoformat())
self.eq(dt.unmarshall(types)['when'], when)
示例5: submit_problem
# 需要导入模块: from pysimplesoap.simplexml import SimpleXMLElement [as 别名]
# 或者: from pysimplesoap.simplexml.SimpleXMLElement import add_child [as 别名]
def submit_problem(url, params):
p = SimpleXMLElement("<submitProblem></submitProblem>")
for k, v in params.items():
child = p.add_child(k, v)
child.add_attribute("xsi:type", "xsd:string")
client = SoapClient(
location = url,
action = '',
soap_ns = 'soapenv',
namespace = 'http://www.decision-deck.org/2009/XMCDA-2.0.0',
trace = False)
sp = client.call('submitProblem', p)
reply = sp.submitProblemResponse
return str(reply.ticket)