简体   繁体   English

Select 带有命名空间的 883812976388 文档的值

[英]Select value of xml document with namespace

I have the following XML snippet我有以下 XML 片段

<aaa>
  <bbb xmlns="http://net.some.address.com">
    <ccc>123321</ccc>
  </bbb>
</aaa>

And i want to select the value of <ccc> with XSL template, but not able to get it by using我想 select <ccc>的值与 XSL 模板,但无法通过使用

<xsl:value-of select="/aaa/bbb/ccc"/>

Any ideas how to get the value without changing the input?任何想法如何在不改变输入的情况下获得价值?

Declare the namespace and use it.声明命名空间并使用它。

<xsl:value-of xmlns:a="http://net.some.address.com" select="/aaa/a:bbb/a:ccc"/>
  • You can pick any prefix you want, it does not have to be a .您可以选择任何您想要的前缀,它不一定a .
  • You can declare the namespace at any point higher up in the XSLT document.您可以在 XSLT 文档中更高层的任何位置声明命名空间。 Usually all namespaces are declared at the <xsl:stylesheet> level, but as you can see, that's just a convention.通常所有名称空间都在<xsl:stylesheet>级别声明,但如您所见,这只是一个约定。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM