I have the following XML document that I have to parse using python's minidom:
<?xml version="1.0" encoding="UTF-8"?>
<root>
<bash-function activated="True">
<name>lsal</name>
<description>List directory content (-al)</description>
<code>ls -al</code>
</bash-function>
<bash-function activated="True">
<name>lsl</name>
<description>List directory content (-l)</description>
<code>ls -l</code>
</bash-function>
</root>
Here is the code (the essential part) where I am trying to parse:
from modules import BashFunction
from xml.dom.minidom import parse
class FuncDoc(object):
def __init__(self, xml_file):
self.active_func = []
self.inactive_func = []
try:
self.dom = parse(xml_file)
except Exception as inst:
print type(inst)
print inst.args
print inst
Unfortunately I am encountering some errors. Here is the stacktrace:
<class 'xml.parsers.expat.ExpatError'>
('no element found: line 1, column 0',)
no element found: line 1, column 0
As a python beginner, can you please point me to the root of the problem.