I am trying to parse .svg files from http://kanjivg.tagaini.net/ , but I cannot successfully extract the information inside.
Edit 1: (full file) http://www.filedropper.com/0f9ab
The part is 0f9ab.svgas follows:
<svg xmlns="http://www.w3.org/2000/svg" width="109" height="109" viewBox="0 0 109 109">
<g id="kvg:StrokePaths_0f9ab" style="fill:none;stroke:#000000;stroke-width:3;stroke-linecap:round;stroke-linejoin:round;">
<g id="kvg:0f9ab" kvg:element="εΆΊ">
<g id="kvg:0f9ab-g1" kvg:element="ε±±" kvg:position="top" kvg:radical="general">
<path id="kvg:0f9ab-s1" kvg:type="γa" d="M53.26,9.38c0.99,0.99,1.12,2.09,1.12,3.12c0,0.67,0.06,8.38,0.06,13.01"/>
<path id="kvg:0f9ab-s2" kvg:type="γa"
</g>
</g>
</g>
My .py file:
import lxml.etree as ET
svg = ET.parse('0f9ab.svg')
print(svg)
print(svg.tag)
print(svg[0])
for child in svg:
print(child)
print(svg.find("./svg"))
print(svg.findall("//g"))
print(svg.xpath("//g"))
purpose
I tried all kinds of operations that I could think of, but nothing gives me any data from the .svg file. I want to extract kanji (Japanese character) in kvg:element="kanji"(which are at different levels of depth).
Question
- Uses the
lxmlwrong package for this? - If not, how do I extract information from my .svg syntax file?
Another solution
- , ,
kvg:element=", xml
/svg. xmltodict, kvg:element, .