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

Popular posts from this blog

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -