import aspose.svg import os from aspose.svg import * path = "C://" # Specify SVG content documentContent = "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"400\" height=\"400\">"" <line x1=\"50\" y1=\"50\" x2=\"350\" y2=\"350\" stroke=\"black\" stroke-width=\"2\" /></svg>" # Instantiate an SVGDocument object document = SVGDocument(documentContent, ".") # Get root svg element of the document svg_element = document.root_element # Access the line segment lineElement = svg_element.query_selector("line") # Save the SVG document to a file output_path = os.path.join(path, "BeforeRotation.svg") document.save(output_path) # Set a transform attribute value lineElement.set_attribute("transform", "rotate(-90 200 265)") # Save the SVG file document.save("AfterRotation.svg")