parsing SVG files using Java and converting fetched element to string
Nonsense not to say, directly on the code, there are not a few lines of code, I believe we can read.
Resolves the svg public static string Parsesvg (String Svguri) throws Exception {File File = new file (Svguri);
String parser = Xmlresourcedescriptor.getxmlparserclassname ();
Saxsvgdocumentfactory f = new saxsvgdocumentfactory (parser);
Document doc = f.createdocument (File.touri (). toString ());
Element element = Doc.getelementbyid ("72617072");
String elementstr = convertelemtosvg (Element);
System.out.println (ELEMENTSTR);
return elementstr; ///Convert element to string public static string Convertelemtosvg (element Element) {Transformerfactory transfact
Ory = Transformerfactory.newinstance ();
Transformer Transformer = null;
try {transformer = Transfactory.newtransformer ();
catch (Transformerconfigurationexception e) {e.printstacktrace ();
} StringWriter buffer = new StringWriter (); Transformer.setoutputproperty (Outputkeys.omit_xml_declaratioN, "yes");
try {transformer.transform (new Domsource (Element), new Streamresult (buffer));
catch (Transformerexception e) {e.printstacktrace ();
String elementstr = buffer.tostring ();
return elementstr; }