我想从XML文档中显示以下输出,但我不知道该怎么做。有人可以帮忙吗?
期望的输出:
<?xml version="1.0" encoding="UTF-8"?>
<Integration>
<ProtectionOrderStatus>
<ProtectionOrderStatusCode>DELETED</ext:ProtectionOrderStatusCode>
</ProtectionOrderStatus>
</Integration>
XML文档:
<?xml version="1.0" encoding="UTF-8"?>
<Integration>
<ProtectionOrder>
<Deleted>true</Deleted>
<ProtectionOrderNumber>12</ProtectionOrderNumber>
<Statuses>
<Status>
<Current>true</Current>
<Active>Yes</Active>
<Date>03/16/2017</Date>
<Type Word="SBJO">Signed By Judicial Officer</Type>
</Status>
</Statuses>
</ProtectionOrder>
</Integration>
答案 0 :(得分:1)
我不知道您的处理语言是什么 所以我只提供XSLT-1.0实现此目的的方法:
<?xml version="1.0"?>
<Integration>
<ProtectionOrderStatus>
<ProtectionOrderStatusCode>DELETED</ProtectionOrderStatusCode>
</ProtectionOrderStatus>
</Integration>
它的输出是:
ProtectionOrderStatus
此代码为源XML的每个<ProtectionOrder>
元素生成<Deleted>
元素,该元素具有text()
子元素,true
值等于{{1}}