我有以下从restapi获得的XML文件
<?xml version="1.0" encoding="utf-8"?> <boxes> <home id="1" name="productname"/> <server>111.111.111.111</server> <approved>yes</approved> <creation>2007 handmade</creation> <description>E-Commerce, buying and selling both attested</description> <boxtype> <sizes>large, medium, small</sizes> <vendor>Some Organization</vendor> <version>ANY</version> </boxtype> <method>Handmade, Handcrafted</method> <time>2014</time> </boxes>
我可以得到上面的输出,存储在字符串变量中并在控制台中打印
但是当我把这个发送到xml ElementTree时
import base64
import urllib2
from xml.dom.minidom import Node, Document, parseString
from xml.etree import ElementTree as ET
from xml.etree.ElementTree import XML, fromstring, tostring
print outputxml ##Printing xml correctly, outputxml contains xml above
content = ET.fromstring(outputxml)
boxes = content.find('boxes')
print boxes
boxtype = boxes.find("boxes/boxtype")
如果我打印这些框,它会给我None
,因此会给出下面的错误
根级节点是}。在
boxes
,它在自身内部找不到{应该足够了。在
演示:
^{pr2}$相关问题 更多 >
编程相关推荐