#107·videos

xml.etree.ElementTree.ParseError: syntax error: line 1, column 0 (and temporary solution)

Author: ElteoremadebeethovenCreated Dec 19, 2024Updated Jun 8, 2025

I have this error using Fedora 40, python3.11 and python3.12 when using LaTeX:

  File "/home/zavden/Manim/mgl_test/manimlib/mobject/svg/svg_mobject.py", line 128, in mobjects_from_svg_string
    element_tree = ET.ElementTree(ET.fromstring(svg_string))
                                  ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.12/xml/etree/ElementTree.py", line 1335, in XML
    parser.feed(text)
xml.etree.ElementTree.ParseError: syntax error: line 1, column 0

In svg_mobject.py, line 128 I printed the variable "svg_string", and I noticed that this message was printed before the xml:

The old, written in PostScript, PDF interpreter has been removed entirely.
You should cease using -dNEWDPF as it has no effect n<?xml version='1.0' encoding='UTF-8'?>

I don't know how to solve it directly using ET, so I solved it by removing that text manually (line 127):

python
    def mobjects_from_svg_string(self, svg_string: str) -> list[VMobject]:
        header_in_xml = svg_string.find("<?xml") #
        if header_in_xml != -1: #
          svg_string = svg_string[header_in_xml:] #
        element_tree = ET.ElementTree(ET.fromstring(svg_string))

And this solves the bug, but if anyone has a more elegant solution using ET, feel free to comment.

Thank you,