使用正确的xpath捕获值

时间:2019-05-16 16:49:04

标签: xml xslt xslt-1.0 xslt-2.0

我具有以下XML结构,并且我试图仅捕获消息“ TypeError: null is not an object (evaluating 'currentMarker.showCallout') This error is located at: in App (at renderApplication.js:35) in RCTView (at View.js:45) in View (at AppContainer.js:98) in RCTView (at View.js:45) in View (at AppContainer.js:115) in AppContainer (at renderApplication.js:34) setMarkerRefresh ”。但是,当我阅读元素/ messageText时,我得到了其中的完整元素。是否可以单独阅读以粗体突出显示的消息?

This is a sample message

1 个答案:

答案 0 :(得分:2)

这应该给您一个想法。基本上是在选择text()元素的子messageText节点。不是text()元素的子accessibilityText节点。

 <xsl:template match="messageText">
    <xsl:copy-of select="text()"/>
  </xsl:template>

或这个

 <xsl:copy-of select="messageText/text()"/>