当前位置: 首页>>代码示例>>Python>>正文


Python SimpleXMLElement.as_xml方法代码示例

本文整理汇总了Python中pysimplesoap.simplexml.SimpleXMLElement.as_xml方法的典型用法代码示例。如果您正苦于以下问题:Python SimpleXMLElement.as_xml方法的具体用法?Python SimpleXMLElement.as_xml怎么用?Python SimpleXMLElement.as_xml使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pysimplesoap.simplexml.SimpleXMLElement的用法示例。


在下文中一共展示了SimpleXMLElement.as_xml方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: serializar

# 需要导入模块: from pysimplesoap.simplexml import SimpleXMLElement [as 别名]
# 或者: from pysimplesoap.simplexml.SimpleXMLElement import as_xml [as 别名]
def serializar(regs):
    "Dado una lista de comprobantes (diccionarios), convierte a xml"
    xml = SimpleXMLElement(XML_BASE)

    comprobantes = []
    for reg in regs:
        dic = {}
        for k, v in MAP_ENC.items():
            dic[v] = reg[k]
                
        dic.update({
                'detalles': [{
                    'detalle': mapear({}, det, MAP_DET, swap=True),
                    } for det in reg['detalles']],                
                'tributos': [{
                    'tributo': mapear({}, trib, MAP_TRIB, swap=True),
                    } for trib in reg['tributos']],
                'ivas': [{
                    'iva': mapear({}, iva, MAP_IVA, swap=True),
                    } for iva in reg['ivas']],
                'formaspago': [{
                'formapago': {
                    'codigo': '',
                    'descripcion': reg['forma_pago'],
                    }}]
                })
        comprobantes.append(dic)

    for comprobante in comprobantes:
        xml.marshall("comprobante", comprobante)
    return xml.as_xml()
开发者ID:AndresVillan,项目名称:pyafipws,代码行数:33,代码来源:formato_xml.py

示例2: makeNRPSrequest

# 需要导入模块: from pysimplesoap.simplexml import SimpleXMLElement [as 别名]
# 或者: from pysimplesoap.simplexml.SimpleXMLElement import as_xml [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
开发者ID:roettig,项目名称:NRPSpredictor2,代码行数:19,代码来源:soap_request.py

示例3: test_marshall_cdata

# 需要导入模块: from pysimplesoap.simplexml import SimpleXMLElement [as 别名]
# 或者: from pysimplesoap.simplexml.SimpleXMLElement import as_xml [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'))
开发者ID:JAVTAMVI,项目名称:pysimplesoap,代码行数:10,代码来源:simplexmlelement_test.py

示例4: test_basic

# 需要导入模块: from pysimplesoap.simplexml import SimpleXMLElement [as 别名]
# 或者: from pysimplesoap.simplexml.SimpleXMLElement import as_xml [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)
开发者ID:anzenehansen,项目名称:pysimplesoap,代码行数:25,代码来源:simplexmlelement_test.py

示例5: call

# 需要导入模块: from pysimplesoap.simplexml import SimpleXMLElement [as 别名]
# 或者: from pysimplesoap.simplexml.SimpleXMLElement import as_xml [as 别名]
 def call(self, method, *args, **kwargs):
     "Prepara el xml y realiza la llamada SOAP, devuelve un SimpleXMLElement"
     # Mensaje de Solicitud SOAP básico:
     xml = self.__xml % dict(method=method, namespace=self.namespace, ns=self.__ns,
                             soap_ns=self.__soap_ns, soap_uri=soap_namespaces[self.__soap_ns])
     request = SimpleXMLElement(xml,namespace=self.__ns and self.namespace, prefix=self.__ns)
     # parsear argumentos
     if kwargs:
         parameters = kwargs.items()
     else:
         parameters = args
     for k,v in parameters: # dict: tag=valor
         self.parse(getattr(request,method),k,v)
     self.xml_request = request.as_xml()
     self.xml_response = self.send(method, self.xml_request)
     response = SimpleXMLElement(self.xml_response, namespace=self.namespace)
     if self.exceptions and ("soapenv:Fault" in response or "soap:Fault" in response):
         raise SoapFault(unicode(response.faultcode), unicode(response.faultstring))
     return response
开发者ID:AndresVillan,项目名称:pyafipws,代码行数:21,代码来源:soap.py


注:本文中的pysimplesoap.simplexml.SimpleXMLElement.as_xml方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。