Python的XMLSchema绑定包 PyXB

码农软件 · 软件分类 · XML相关工具 · 2019-09-18 22:29:27

软件介绍

PyXB (“pixbee”) 是一个纯 Python 的类库用来根据 XML Schema 生成对应的 Python 类,开发人员可以使用这些类来操作XML Schema 数据。

示例代码:

import weather
import time
import pyxb.utils.domutils as domutils
import sys
import pyxb.standard.bindings.soapenv as soapenv
import pyxb.standard.bindings.soapenc as soapenc
import urllib2

zip = 85711
if 1 < len(sys.argv):
zip = int(sys.argv[1])

# Create an envelope, and give it a body that is the request for the
# service we want.
env = soapenv.Envelope()
env.setBody(weather.GetCityForecastByZIP(ZIP=zip))

# Invoke the service
uri = urllib2.Request('http://ws.cdyne.com/WeatherWS/Weather.asmx',
env.toxml(),
{ 'SOAPAction' : "http://ws.cdyne.com/WeatherWS/GetCityForecastByZIP", 'Content-Type': 'text/xml' } )
rxml = urllib2.urlopen(uri).read()

# Convert the response to a SOAP envelope, then extract the actual
# response from the wildcard elements of the body. Note that because
# the weather namespace was registered, PyXB already created the
# binding for the response.
soap_resp = soapenv.CreateFromDOM(domutils.StringToDOM(rxml))
resp = soap_resp.Body().wildcardElements()[0]

fc_return = resp.GetCityForecastByZIPResult()
if fc_return.Success():
print 'Got response for %s, %s:' % (fc_return.City(), fc_return.State())
for fc in fc_return.ForecastResult().Forecast():
when = time.strftime('%A, %B %d %Y', fc.Date().timetuple())
outlook = fc.Desciption() # typos in WSDL left unchanged
low = fc.Temperatures().MorningLow()
high = fc.Temperatures().DaytimeHigh()
print ' %s: %s, from %s to %s' % (when, outlook, low, high)

本文地址:https://codercto.com/soft/d/14902.html

海星模式

海星模式

奥瑞·布莱福曼、罗德·贝克斯特朗 / 李江波 / 中信出版社 / 2008-1 / 36.00元

如果砍掉一只蜘蛛的脑袋,毫无疑问它会死掉;但是砍掉海星的一条手臂,它却会长出一只新的来,就连那只砍掉的手臂也会长成一个完整的新海星。传统意义上自上而下的组织模式就像蜘蛛,然而现在正在改变着企业和世界面貌的却是海星型组织。 维基百科、craigslist和Skype的成功下面隐藏着什么样的力量?易趣公司和通用电气公司与废奴和女权运动又有什么共同之处?到底是什么样的重大选择使得通用汽车公司与丰田......一起来看看 《海星模式》 这本书的介绍吧!

JS 压缩/解压工具
JS 压缩/解压工具

在线压缩/解压 JS 代码

正则表达式在线测试
正则表达式在线测试

正则表达式在线测试

RGB HSV 转换
RGB HSV 转换

RGB HSV 互转工具