我有一个XML对象
running_config = <data>
<configuration xmlns="http://xml.juniper.net/xnm/1.1/xnm">
.
.
</configuration>
</data>
The following code works:
rc = self.running_config.find('//config:configuration', namespaces=namespace)
And I can get result:
<configuration xmlns="http://xml.juniper.net/xnm/1.1/xnm"> ..
</configuration>`
<br>***Response received on the client***
但这只是第一次
当再次收到相同的请求时,我观察到running_config
对象被缩减为<data> </data>
(不再存在<configuration>
元素)
因此,rc = self.running_config.find('//config:configuration', namespaces=namespace)
返回None
Here is my code snippet:
rc = self.running_config.find('//config:configuration', namespaces=namespace)
# check if response is expected in json/xml
root = etree.ElementTree(rpc)
config = root.find('//get-configuration', namespaces=namespace)
if 'format' in config.attrib:
if config.attrib['format'] == 'xml':
print 'sending xml response'
return rc
#send response in json
我无法理解这里发生了什么
目前没有回答
相关问题 更多 >
编程相关推荐