exec
我想要如下输出:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="Cdata"><![CDATA[is this correct<b><u><font color=\'#00733E\'>click here.</u></b>]]></string>
<resources>
这是我的代码
Cdata <![CDATA[is this correct<b><u><font color=\'#00733E\'>click here.</u></b>]]>
但不使用Cdata值作为单击此处。
如何获取import xlwt
from xlwt import Workbook
from xml.dom import minidom
wb = Workbook()
sheet1 = wb.add_sheet("Sheet 1", cell_overwrite_ok=True)
mydoc = minidom.parse('strings.xml')
items = mydoc.getElementsByTagName('string')
l = []
row = 0
for elem in items:
try:
sheet1.write(row, 0, elem.attributes['name'].value)
sheet1.write(row, 1, elem.firstChild.data)
except :
sheet1.write(row, 0, elem.attributes['name'].value)
l.append(elem.attributes['name'].value)
row = row +1
wb.save('mastersheet.xls')
print (l)
print ("Done")
值