我不确定如何使用以下代码从<array name="logEntries" type="value" depth="1">
获取值。你知道吗
到目前为止,如果在xml上只有一个数组标记,而不是多个数组标记,那么我现在所拥有的是有效的。你知道吗
#Currently xml_input var is returned from an http request
root = ElementTree.fromstring(xml_input)
for child in root.findall('.array/value'):
print(child)
XML示例:
<?xml version="1.0" encoding="UTF-8"?>
<Values version="2.0">
<array name="logList" type="value" depth="1">
<value>type_log</value>
</array>
<value name="numlines">2</value>
<array name="numlinesList" type="value" depth="1">
<value>2</value>
</array>
<array name="logEntries" type="value" depth="1">
<value>some inputs</value>
<value>other inputs</value>
</array>
</Values>
期望输出:
some inputs
other inputs
简而言之,即使是咨询The ElementTree XML API我也无法发现如何克服这个问题。你知道吗
提前谢谢
试试这个:
相关问题 更多 >
编程相关推荐