I was working with a .pri file. Which has a xml format. Like below.
<?xml version="1.0"?>
<!DOCTYPE text SYSTEM "text.dtd">
<text id="fn000001">
<au id="fn000001.1" s="N00023">
<w id="fn000001.1.1"> hi </w>
<w id="fn000001.1.2"> there </w>
<l id="fn000001.1.3"> ? </l>
</au>
</text>
Now if I call a single file, by using below command, it works properly.
import xml.etree.ElementTree as ET
tree = ET.parse('/path/fn000001.pri')
root = tree.getroot()
print(root.get('id'))
Now I want to apply this to all the .pri files in the folder. For that, I am using below command,
import glob
import xml.etree.ElementTree as ET
a = glob.glob('/path/*.pri')
for files in a:
tree = ET.parse(files)
print(tree)
That throws the error,
tree = ET.parse(files)
File "/usr/lib/python3.6/xml/etree/ElementTree.py", line 1196, in parse
tree.parse(source, parser)
File "/usr/lib/python3.6/xml/etree/ElementTree.py", line 597, in parse
self._root = parser._parse_whole(source)
xml.etree.ElementTree.ParseError: undefined entity è: line 147, column 52
Please suggest possible solutions. The related .dtd
is in the same folder.