我需要使用 java xpath 通过 id 将 xml 元素作为字符串返回。
给...
<svg>
    <g id="Background">
    </g>
    <g id="Outline">
        <polygon fill="none" stroke="#000000" stroke-linecap="round" stroke-linejoin="round"     stroke-miterlimit="10" points=" 119.813,57.875 119.188,57.87" />
    </g>
    <g id="Base_Colour" transform="matrix(0.25 0 0 0.25 0 0)">
        <path fill="#ADB1AF" d="M112.25,208l-8,20.25l-0.5-1.75l0.75-0.5v-1.5l0.75-0.5v-1.5L106,222v-1.5l0.75-0.5v-1.5l0.75-0.5v-1.5"/>
        <path fill="#625595" d="M112.25,208l5.25-14.5l30-30.25l2.25-1.5l41.5-20.5l49.75-9.5h4.25l49,3l48.75"/>
    </g>
</svg>
返回的值必须是...
<g id="Outline">
    <polygon fill="none" stroke="#000000" stroke-linecap="round" stroke-linejoin="round"     stroke-miterlimit="10" points=" 119.813,57.875 119.188,57.87" />
</g> 
我已经广泛搜索,但我尝试过的任何东西都无法返回整个元素。需要 Xpath,因为我想通过 id 查询任何级别的 g 标签。