Repository: ManimCommunity/manim

Issue:
`SVGMobject` cannot parse SVG files correctly
## Description of bug / unexpected behavior
<!-- Add a clear and concise description of the problem you encountered. -->
There are many issues in your `SVGMobject`:
- in `SVGMobject.generate_points`, every element with tag `svg` will be taken in `SVGMobject.get_mobjects_from`. But some of them are nested inside, which are used to generate mobjects for multiple times (this results in a thick line on the far left in the example below)
- in `SVGMobject.handle_transforms`, all transforms are applied from left to right, but should be applied from right to left (this causes the subscripts to be too close to the left text in the example below)

## How to reproduce the issue
<!-- Provide a piece of code illustrating the undesired behavior. -->

<details><summary>Example</summary>

```py
class Code(Scene):
    def construct(self):
        svg = SVGMobject("formula.svg", stroke_opacity=0, color=WHITE)
        self.add(svg)
```
![formula](https://user-images.githubusercontent.com/44120331/150934299-fd0399ed-c43d-47f4-b5bc-9b21bf0557b3.svg)

**Result**:
![image](https://user-images.githubusercontent.com/44120331/150934333-9efe53d0-18b7-4797-951e-c7bf58e8291a.png)

**Expected**:
![image](https://user-images.githubusercontent.com/44120331/150934395-230b42dc-9014-485d-b1ad-4dae33ec79d9.png)

</details>


## Additional comments
<!-- Add further context that you think might be relevant for this issue here. -->
See also: https://github.com/3b1b/manim/pull/1712



Discussion:

Resolving patch:
diff --git a/manim/mobject/svg/svg_mobject.py b/manim/mobject/svg/svg_mobject.py
--- a/manim/mobject/svg/svg_mobject.py
+++ b/manim/mobject/svg/svg_mobject.py
@@ -133,8 +133,10 @@ def generate_points(self):
         any submobjects within self.mobjects.
         """
         doc = minidom_parse(self.file_path)
-        for svg in doc.getElementsByTagName("svg"):
-            mobjects = self._get_mobjects_from(svg, self.generate_style())
+        for node in doc.childNodes:
+            if not isinstance(node, MinidomElement) or node.tagName != "svg":
+                continue
+            mobjects = self._get_mobjects_from(node, self.generate_style())
             if self.unpack_groups:
                 self.add(*mobjects)
             else:
@@ -484,11 +486,13 @@ def _handle_transforms(self, element, mobject):
             The Mobject to transform.
         """
 
-        if element.hasAttribute("x") and element.hasAttribute("y"):
-            x = self._attribute_to_float(element.getAttribute("x"))
-            # Flip y
-            y = -self._attribute_to_float(element.getAttribute("y"))
-            mobject.shift(x * RIGHT + y * UP)
+        x, y = (
+            self._attribute_to_float(element.getAttribute(key))
+            if element.hasAttribute(key)
+            else 0.0
+            for key in ("x", "y")
+        )
+        mobject.shift(x * RIGHT + y * DOWN)
 
         transform_attr_value = element.getAttribute("transform")
 
@@ -502,7 +506,7 @@ def _handle_transforms(self, element, mobject):
         # [^)]*    == anything but a closing parenthesis
         # '|'.join == OR-list of SVG transformations
         transform_regex = "|".join([x + r"[^)]*\)" for x in transform_names])
-        transforms = re.findall(transform_regex, transform_attr_value)
+        transforms = re.findall(transform_regex, transform_attr_value)[::-1]
 
         number_regex = r"[-+]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][-+]?\d+)?"
 


Test patch:
diff --git a/tests/test_graphical_units/control_data/img_and_svg/MultipleTransform.npz b/tests/test_graphical_units/control_data/img_and_svg/MultipleTransform.npz
Binary files a/tests/test_graphical_units/control_data/img_and_svg/MultipleTransform.npz and b/tests/test_graphical_units/control_data/img_and_svg/MultipleTransform.npz differ