Thursday, 8 March 2018

python parse xml text




I would like to parse xml in python, but as a string, not taken from a file. Can someone help me do this?


Answer



From a file, you could normally do it as




from xml.dom import minidom                                          
xmldoc = minidom.parse('~/diveintopython/common/py/kgp/binary.xml')


For a string, you can change it to



from xml.dom import minidom                                          
xmldoc = minidom.parseString( Your string goes here )


No comments:

Post a Comment

casting - Why wasn't Tobey Maguire in The Amazing Spider-Man? - Movies & TV

In the Spider-Man franchise, Tobey Maguire is an outstanding performer as a Spider-Man and also reprised his role in the sequels Spider-Man...