MicroSvgParser { static Group readSvg(InputStream in, DoubleProperty svgWidth, DoubleProperty svgHeight, ObjectProperty<Paint> svgFill) throws Exception { NodeList paths = (NodeList) XPathFactory.newDefaultInstance().newXPath().evaluate("/svg/g/path", DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(in), XPathConstants.NODESET); Group group = new Group(); for (int i = 0; i < paths.getLength(); i++) { NamedNodeMap attributes = paths.item(i).getAttributes(); SVGPath path = new SVGPath(); var fill = attributes.getNamedItem("fill"); if (fill != null) path.setFill(fill.getTextContent().equals("none") ? Color.TRANSPARENT : Paint.valueOf(fill.getTextContent())); else if (svgFill.get() != null) path.setFill(svgFill.get()); var fillRule = attributes.getNamedItem("fill-rule"); if (fillRule != null) switch (fillRule.getTextContent()) { case "evenodd": path.setFillRule(FillRule.EVEN_ODD); break; case "nonzero": path.setFillRule(FillRule.NON_ZERO); break; default: log.warn("Unknown fill-rule: " + fillRule.getTextContent()); break; } var d = attributes.getNamedItem("d"); if (d != null) path.setContent(d.getTextContent()); var style = attributes.getNamedItem("style"); if (style != null) path.setStyle(style.getTextContent()); group.getChildren().add(path); } group.scaleXProperty().bind(Bindings.divide(svgWidth, group.getBoundsInParent().getWidth())); group.scaleYProperty().bind(Bindings.divide(svgHeight, group.getBoundsInParent().getHeight())); return group; }  static Node getSvg(String url, DoubleProperty svgWidth, DoubleProperty svgHeight,
			ObjectProperty<Paint> svgFill);  }
@Test @DisplayName("Test a simple SVG") void readSvg_1() throws Exception { InputStream in = new ByteArrayInputStream( "<svg xmlns=\"http: .getBytes()); Group svg = readSvg(in, new SimpleDoubleProperty(64), new SimpleDoubleProperty(64), new SimpleObjectProperty<Paint>(null)); assertNotNull(svg); assertEquals(64, svg.getBoundsInParent().getWidth()); assertEquals(64, svg.getBoundsInParent().getHeight()); assertEquals(2, svg.getChildren().size()); assertEquals("M0 0h24v24H0z", ((SVGPath) svg.getChildren().get(0)).getContent()); assertEquals("M3 4h18v2H3V4zm0 7h18v2H3v-2zm0 7h18v2H3v-2z", ((SVGPath) svg.getChildren().get(1)).getContent()); }