From 7fb66815212e11014742624dcc0015f52681c17e Mon Sep 17 00:00:00 2001 From: Thomas Guillet Date: Wed, 9 Dec 2020 11:08:54 +0100 Subject: [PATCH] Process path within an explicit SVG namespace --- svgpathtools/svg_to_paths.py | 2 +- test/namespaces.svg | 7 +++++++ test/test_svg2paths.py | 9 +++++++++ 3 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 test/namespaces.svg diff --git a/svgpathtools/svg_to_paths.py b/svgpathtools/svg_to_paths.py index 2dff80a..42fd7cf 100644 --- a/svgpathtools/svg_to_paths.py +++ b/svgpathtools/svg_to_paths.py @@ -153,7 +153,7 @@ def dom2dict(element): return dict(list(zip(keys, values))) # Use minidom to extract path strings from input SVG - paths = [dom2dict(el) for el in doc.getElementsByTagName('path')] + paths = [dom2dict(el) for el in doc.getElementsByTagNameNS('http://www.w3.org/2000/svg', 'path')] d_strings = [el['d'] for el in paths] attribute_dictionary_list = paths diff --git a/test/namespaces.svg b/test/namespaces.svg new file mode 100644 index 0000000..b32a1b0 --- /dev/null +++ b/test/namespaces.svg @@ -0,0 +1,7 @@ + + + + + + + diff --git a/test/test_svg2paths.py b/test/test_svg2paths.py index 90a23e0..2c958a7 100644 --- a/test/test_svg2paths.py +++ b/test/test_svg2paths.py @@ -50,3 +50,12 @@ def test_svg2paths_ellipses(self): self.assertTrue(len(path_circle)==2) self.assertTrue(path_circle==path_circle_correct) self.assertTrue(path_circle.isclosed()) + + def test_svg2paths_namespaces(self): + + paths, _ = svg2paths(join(dirname(__file__), 'namespaces.svg')) + self.assertTrue(len(paths)==1) + + +if __name__ == '__main__': + unittest.main()