How to parse XML file in Python when the value of an attribute is integer instead of character string -
i try parse xml file looks like:
<?xml version="1.0" encoding="utf-8"?> <config> <basic logdir = "../log/" workthreadcnt=1 maxday="180" /> </config>
i used xml.dom.minidom, such as:
from xml.dom.minidom import parse import xml.dom.minidom domtree = xml.dom.minidom.parse("cfg.xml")
and used xml.etree.elementtree, such as:
import xml.etree.elementtree et tree = et.parse("cfg.xml")
both of them didn't work until changed attribute
workthreadcnt=1
to
workthreadcnt="1"
my questions is: if insist on using first format,how make work ?
Comments
Post a Comment