这个问题基本上都说明了一切。如何检查SVG是否具有viewBox属性?我正在使用Batik lib。我需要这个,因为我需要(至少)通知用户有一个viewBox属性。
我可以删除吗?
答案 0 :(得分:1)
使用org.w3c.dom类你可以沿着这些方向做点什么......
String parser = XMLResourceDescriptor.getXMLParserClassName();
SAXSVGDocumentFactory f = new SAXSVGDocumentFactory(parser);
URL url = new URL(getCodeBase(), "fileName.svg");
Document doc = f.createDocument(url.toString());
Element svg = doc.getDocumentElement();
if (svg.hasAttribute("viewBox")) {
// notify the user somehow
}
删除电话
svg.removeAttribute("viewBox")