Good evening, i have to work on a xml file, the problem is that the elements in the file ends with a different format than usual, for example:
<1ELEMENT>
text
<\1ELEMENT>
I use the function root=etree.parse('filepath'), and, by changing manually in the text out of the compiler the \ in /, the function works correctly.
The big problem is that i need to automate that replacing process and the only solution that i thinked about is importing the file as array make a replace / to \ and build a new xml file;but it seems a little bit clunky.
Summing up i need to know if exist a function to replace the terms i mentioned above before to use the root=etree.parse('filepath').
This isn't an XML file.
Given that the format of the file is garbage, are you sure the content isn't garbage too? I wouldn't want to work with data from such an untrustworthy source.
If you want to parse this data you will need to work out what rules it follows. If those rules are something fairly similar to XML rules then it might be that converting it to XML and then parsing the XML is a reasonable way to go about this; if not, you might be better off writing a parser from scratch.
But before you do so, try to persuade the people responsible for this nonsense of the benefits of conforming to standards.
(python) parsing xml file but the elements ends with \