【发布时间】:2017-10-30 17:28:40
【问题描述】:
我正在尝试编写一个 Python 脚本,该脚本将通过 Rows 并将它们放入我的数据库中
这是我的xml的结构:
Root>
-<SvcNf>
-<PersonNf>
-<PersonList>
-<Row>
<SysName>MI6</SysName>
<ServerDt>2016-10-28 03:00:12 +03:00</ServerDt>
<UID>9457A55E17341AA7ASDEDS057A8BFFF3</UID>
<PersID>007</PersID>
<Emp_name>James Bond</Emp_name>
<EventID>25</EventID>
<EventTXT>Drinking alcohol</EventTXT>
<CauseEventID>03</CauseEventID>
<CauseEventTXT>Martini with vodka</CauseEventTXT>
<EventBegda>2017-10-18</EventBegda>
<EventEndda>2017-10-18</EventEndda>
<AccrualsSum>171.0</AccrualsSum>
<AccrualsProz>0.0</AccrualsProz>
<AccrualsName>Chinees_</AccrualsName>
<OrderNum>P-336</OrderNum>
<Perg>0</Persg>
<Perk>15</Persk>
<Awart/>
</Row>
-<Row>
.....
</Row>
<Row/>
</PersonList>
</PersonNf>
</SvcNf>
</Root>
所以,当我使用这段代码解析 XML 时:
ResultSet_Py_List = []
root = ET.parse(events)
nodes = root.findall('.//Row')
for node in nodes:
for child in node:
ResultSet_Py_List.append(child.text)
我想要的标称行值是
['MI6'、'2016-10-28 03:00:12 +03:00'、'9457A55E17341AA7ASDEDS057A8BFFF3'等]
[Row2]
[Row3]
现在,它就像: [Row1,Row2,Row3]
[编辑]
所有字符都像&#1060。
治愈它:
tostring(doc.getroot(), 'unicode')
[编辑]
我使用了第二个示例,但现在出现了 Oracle 错误:ORA-01704: string literal too long.
【问题讨论】:
-
@Максим Федоров,所以在每一行结束后它的“无”分隔行对吗?
-
@Parfait - Oracle 11G 数据库
-
@Chetan Vasudevan - 不像往常一样,
不能为空 -
@МаксимФедоров,那么哪个可以是行之间分隔的因素/键?
-
MI6 - 这是行之间的分隔,始终 = 常量
标签: python xml parsing plsql cx-oracle