My job is to parse XML files and retrieve various reports. I also create and edit XML files using etree in Python. Most of the time, i am stuck in files with custom entities like mdash, nbsp, and so on.
I browsed and found one solution mentioned here Python ElementTree support for parsing unknown XML entities?
So i added the entity definition [!ENTITY nbsp " ] and worked on it.It works but i need to read them as string, add the entity definition to it, and then carry on my work.
Is this the only way? If i want to parse the XML files with custom entities without adding them to the file, can i do that?
Is there a way to define those entities in the script and parse the XMl files?