【问题标题】:Access DOM attribute with XML namespace on Freemarker template在 Freemarker 模板上使用 XML 命名空间访问 DOM 属性
【发布时间】:2016-01-31 22:33:48
【问题描述】:

我有以下 XML。

<n:wmi xmlns:inventory="http://www.example.com/XMLSchema/mp/v1/item/ItemInventory.xsd" >
<items processMode="INCREMENTAL">
  <item partnerItemId="SM-290754-US">
    <action>UPDATE</action>
    <inventory:availability code="AC" onHandQty="124" />
  </item>
</items>

我想访问 Freemarker 模板中的“代码”属性。以下是我的 freemarker 模板。

我尝试了以下模板。但它们都不起作用。

<#ftl ns_prefixes={"inventory":"http://www.example.com/XMLSchema/mp/v1/item/ItemInventory.xsd"}>${item["inventory:availability[@code]"]}

和

<#ftl ns_prefixes={"inventory":"http://www.example.com/XMLSchema/mp/v1/item/ItemInventory.xsd"}>${item["inventory:availability.@code"]}

【问题讨论】:

    标签: freemarker


    【解决方案1】:

    我做了更多调查。正确的 xpath 将是

    ${item["inventory:availability/@code"]}
    

    【讨论】:

      猜你喜欢
      • 2018-05-14
      • 1970-01-01
      • 2011-01-15
      • 1970-01-01
      • 2010-12-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-05-01
      相关资源
      最近更新 更多