XPATH Befehl SVG Java
06.02.2012
13:48:24 Uhr378 Aufrufe
13:48:24 Uhr
Noch nicht bewertet
Hallo Foren User,
ich möchte eine SVG Grafik über DOM einlesen.
Bei einem XML funktioniert das ohne Probleme, da ich in einem Beispieldokument keine Unterknoten habe.
Bei meiner SVG Grafik sieht das so aus.
Wie komme ich nun an die einzelnen Metadaten (width, heigtht...) heran?
Im moment versuche ich es über eine XPath Funktion.
Über "XPathExpression expr = xpath.compile("//g/rect");" funktiont es nicht.
Danke & Grüße,
AMStyles
ich möchte eine SVG Grafik über DOM einlesen.
Bei einem XML funktioniert das ohne Probleme, da ich in einem Beispieldokument keine Unterknoten habe.
Bei meiner SVG Grafik sieht das so aus.
01.
<svg 02.
. 03.
. 04.
. 05.
. 06.
<g 07.
inkscape:label="Ebene 1" 08.
inkscape:groupmode="layer" 09.
id="layer1" 10.
transform="translate(0,-752.36218)"> 11.
<rect 12.
style="fill:#0000ff;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" 13.
id="rect2985" 14.
width="94.827583" 15.
height="94.827583" 16.
x="31.896551" 17.
y="13.793103" 18.
transform="translate(0,752.36218)" /> 19.
</g> 20.
</svg>Wie komme ich nun an die einzelnen Metadaten (width, heigtht...) heran?
Im moment versuche ich es über eine XPath Funktion.
01.
DocumentBuilderFactory domFactory = DocumentBuilderFactory.newInstance(); 02.
domFactory.setNamespaceAware(true); // never forget this! 03.
DocumentBuilder builder = domFactory.newDocumentBuilder(); 04.
Document doc = builder.parse("c:\\myfile.xml"); 05.
06.
XPathFactory factory = XPathFactory.newInstance(); 07.
XPath xpath = factory.newXPath(); 08.
XPathExpression expr = xpath.compile("//book[author='Neal Stephenson']/title/text()");Über "XPathExpression expr = xpath.compile("//g/rect");" funktiont es nicht.
Danke & Grüße,
AMStyles









