我正在尝试获取其<Opening>'s<PlanarGeometry><Polyloop>>个数为4的所有CartesianPoint标记。
XML标记表面是另一个的子表面。

<Surface id="su-137" surfaceType="InteriorWall" constructionIdRef="ASHIW23" xmlns="http://www.gbxml.org/schema">
 <Name>W-106-114-I-W-137</Name>
 <Opening id="su-137-op-1" openingType="NonSlidingDoor" constructionIdRef="MDOOR">
 <Name>W-106-114-I-W-137-D-1</Name>
   <PlanarGeometry>
      <PolyLoop>
         <CartesianPoint><Coordinate>55.570238</Coordinate><Coordinate>92.571596</Coordinate>
         <Coordinate>0.000000</Coordinate></CartesianPoint><CartesianPoint>         <Coordinate>55.570238</Coordinate><Coordinate>92.571596</Coordinate><Coordinate>6.666667</Coordinate>
         </CartesianPoint>
         <CartesianPoint>
         <Coordinate>55.570238</Coordinate><Coordinate>95.571596</Coordinate><Coordinate>6.666667</Coordinate></CartesianPoint>
         <CartesianPoint>
         <Coordinate>55.570238</Coordinate><Coordinate>95.571596</Coordinate><Coordinate>0.000000</Coordinate>
        </CartesianPoint>
     </PolyLoop>
   </PlanarGeometry>
 </Opening>
</Surface>

我从这个-Xpath to select only nodes where child elements exist?得到了很少的参考,所以线程从下面的示例得到了很少的帮助。
book[author/degree]
All <book> elements that contain <author> children that in turn contain at least one <degree> child.

如何使用xpath或其他方式实现此目标????

最佳答案

我正在尝试获取其cartesianpoint>4的所有<Opening>标记。
假设<PlanarGeometry>元素是当前上下文节点,则:

gb:Opening[gb:PlanarGeometry/gb:Polyloop[count(gb:CartesianPoint) > 4]]

需要将<Polyloop>前缀映射到Surface命名空间uri。这将选择所有gb元素,这些元素至少包含一个http://www.gbxml.org/schema子元素,且子元素多于4个Opening子元素。

09-30 17:40
查看更多