0

我正在尝试调整一个配方来解析一个 xml 提要(http://data.gov.uk/dataset/car-parks

我可以使用 objectify 解析文档,但结果是这样的......

u"{ http://www.transportdirect.info/carparking }CarPark = 无 [ObjectifiedElement]\n { http://www.transportdirect.info/carparking }CarParkRef = 4401 [IntElement]\n { http://www .transportdirect.info / carparking }CarParkName = '华莱士街' [StringElement]\n { http://www.transportdirect.info/carparking }Location = 'Galston' [StringElement]\n { http://www.transportdirect. info/carparking }地址 = 'Henrietta Street--Galston--East Ayrshire' [StringElement]\n { http://www.transportdirect.info/carparking }邮政编码 = 'KA4 8HP' [StringElement]\n...

然后我使用了代码

for elt in root.CarPark:
    el_data = {}
    for child in elt.getchildren():
        el_data[child.tag] = child
    data.append(el_data)

它返回类似 [{'{ http://www.transportdirect.info/carparking }AccessPoints': http://www.transportdirect.info/carparking}AccessPoints at 0x1150a8cd0>, '{ http://www.transportdirect. info/carparking }Address': 'Nunnery Lane--York--Yorkshire', '{ http://www.transportdirect.info/carparking }CarParkAdditionalData': http://www.transportdirect.info/carparking}CarParkAdditionalData at 0x1150a8d20 >, '{ http://www.transportdirect.info/carparking }CarParkName': '尼姑庵',

...

但是当我尝试将其放入数据框中时:

{ http://www.transportdirect.info/carparking }接入点 [[[, , ], [, , ], [, , ]], [[, , ], [, , ], [,... { http ://www.transportdirect.info/carparking }地址 [[[Nunnery Lane--York--Yorkshire]]] { http://www.transportdirect.info/carparking }CarParkAdditionalData [[[]]] { http:// /www.transportdirect.info/carparking }CarParkName [[[Nunnery Lane]]] { http://www.transportdirect.info/carparking }CarParkOperator [[[]]] { http://www.transportdirect.info/carparking }CarParkRef [[[3]]] {http://www.transportdirect.info/carparking }DateRecordLastUpdated [[[2013-06-18]]]

我缺少什么额外的步骤来清理它以使其正常工作?

4

0 回答 0