【发布时间】:2014-08-18 07:58:37
【问题描述】:
我有一个场景,我想从输入 XML 中的 XML 标记复制所有属性,包括命名空间 [这里我的意思是整个属性列表和命名空间列表,而不仅仅是属性的值]。
例如:
输入 XML:
<?xml version="1.0" encoding="UTF-8"?>
<enricher>
<result>
<xbrl xmlns="http://www.xbrl.org/2003/instance"
xmlns:idp-com="http://www.dnb.com/IDP/Common/Vers1"
xmlns:idp-enumcom="http://www.dnb.com/IDP/Common/Enumeration/Common/Vers1"
xsi:schemaLocation="http://www.dnb.com/IDP/Product/Common/Vers1 ../Common/ProductCommonTaxonomy.xsd
http://www.dnb.com/IDP/Common/Vers1 ../../Data/Common/CommonTaxonomy.xsd">
<context id="defaultI">
<entity>
<identifier scheme="http://www.dnb.com">Text</identifier>
</entity>
<period>
<instant>2000-07-14</instant>
</period>
</context>
</xbrl>
</result>
</enricher>
输出 XML:
<?xml version="1.0" encoding="UTF-8"?>
<enricher>
<result>
<xbrlresp xmlns="http://www.xbrl.org/2003/instance"
xmlns:idp-com="http://www.dnb.com/IDP/Common/Vers1"
xmlns:idp-enumcom="http://www.dnb.com/IDP/Common/Enumeration/Common/Vers1"
xsi:schemaLocation="http://www.dnb.com/IDP/Product/Common/Vers1 ../Common/ProductCommonTaxonomy.xsd
http://www.dnb.com/IDP/Common/Vers1 ../../Data/Common/CommonTaxonomy.xsd">
<context id="defaultI">
<entity>
<identifier scheme="http://www.dnb.com">Text</identifier>
</entity>
<period>
<instant>2000-07-14</instant>
</period>
</context>
</xbrlresp>
</result>
</enricher>
输出应包含<xbrlresp> 标记,其中包含<xbrl> 的所有命名空间和属性。
【问题讨论】:
-
嗨,为什么要更改这个 7 年前的问题的命名空间 URI?我回滚了您的编辑(并拒绝了对我的答案的更改)-因为您没有给出任何解释。