解讀 SVG 檔案 - 40123224/cdw2 GitHub Wiki
from xml.dom import minidom
svg_file = "cd_task1_chain_ss.svg"
利用 minidom 解讀 svg 檔案
doc = minidom.parse(svg_file)
設法取得 svg 檔案的長與寬, 並且去除 mm 單位字串
width = float([path.getAttribute('width') for path in doc.getElementsByTagName('svg')][0].replace("mm", ""))
height = float([path.getAttribute('height') for path in doc.getElementsByTagName('svg')][0].replace("mm", ""))
取得 svg 的路徑字串
path_strings = [path.getAttribute('d') for path in doc.getElementsByTagName('path')][0]
doc.unlink()
print("width:", width, "\nheight:", height, "\npath:", path_strings)