1

I have and not well-formed error when trying to parser and string with minidom and ElementTree. In both cases happen when it closes the 2nd attribute (<\cause>)

Here is my code

from xml.dom import minidom
import xml.etree.ElementTree as ET

data = minidom.parseString("<happy>Lennox has always truly wanted to fight for the world title and was happy <cause>taking the tough route<\cause> . <\happy>")

error:

ExpatError                                Traceback (most recent call last)
<ipython-input-23-eda56dc52723> in <module>
----> 1 data = minidom.parseString("<happy>Lennox has always truly wanted to fight for the world title and was happy <cause>taking the tough route<\cause> . <\happy>")

~/anaconda3/envs/nlg_emotions/lib/python3.6/xml/dom/minidom.py in parseString(string, parser)
   1966     if parser is None:
   1967         from xml.dom import expatbuilder
-> 1968         return expatbuilder.parseString(string)
   1969     else:
   1970         from xml.dom import pulldom

~/anaconda3/envs/nlg_emotions/lib/python3.6/xml/dom/expatbuilder.py in parseString(string, namespaces)
    923     else:
    924         builder = ExpatBuilder()
--> 925     return builder.parseString(string)
    926 
    927 

~/anaconda3/envs/nlg_emotions/lib/python3.6/xml/dom/expatbuilder.py in parseString(self, string)
    221         parser = self.getParser()
    222         try:
--> 223             parser.Parse(string, True)
    224             self._setup_subset(string)
    225         except ParseEscape:

ExpatError: not well-formed (invalid token): line 1, column 111
Sinh Nguyen
  • 4,277
  • 3
  • 18
  • 26
YarikMR
  • 11
  • 1

0 Answers0