【发布时间】:2017-05-17 05:14:20
【问题描述】:
我有一个 svg,其中包含以下内容(已删减):
<svg
xmlns="http://www.w3.org/2000/svg"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape">
<g
inkscape:label="base"
inkscape:groupmode="layer"
id="layer1"
transform="translate(0,-600)">
<image
sodipodi:absref="/Untitled.png"
xlink:href="/Untitled.png"
width="800"
height="500"
preserveAspectRatio="none"
id="image5168"
x="3.67"
y="596" />
</g>
<g
inkscape:groupmode="layer"
id="layer30"
inkscape:label="triangle">
<path
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="M 273,340 290,127 563,307 Z"
id="path5174"
inkscape:connector-curvature="0" />
</g>
</svg>
当我查询时:
xmlstarlet sel -t -v "//_:svg/_:g/@inkscape:label" drawing.svg
我明白了:
base
triangle
我一直在研究条件,但我找不到选择 g 的 inkscape:label 的方法,前提是它包含 path 节点 [否则,如果它不包含image节点]。
【问题讨论】:
标签: xml svg xpath xmlstarlet