使用复制时如何使 XmlStarlet 保留 CDATA?<![CDATA[ ]]>
必须维护,因为生成(和使用)数据的应用程序坚持使用 CDATA 指令围绕某些数据。
示例.xml
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<RSLogix5000Content SchemaRevision="1.0" SoftwareRevision="20.01" >
<Controller Use="Target" Name="SOME_TARGET_NAME" ProcessorType="1789-L60">
<Tags>
<Tag Name="gstrScrap" TagType="Base" DataType="STRING" Constant="false" ExternalAccess="Read/Write">
<Data>05 00 00 00 53 43 52 41 50 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00</Data>
<Data Format="String" Length="5">
<![CDATA['SCRAP']]>
</Data>
</Tag>
</Tags>
</Controller>
</RSLogix5000Content>
使用命令;
xml sel -t -c "RSLogix5000Content/Controller/Tags/Tag" Example.xml
生成应用程序无法处理的数据,因为<![CDATA[ ]]>
已从'SCRAP'周围删除;
<Tag Name="gstrScrap" TagType="Base" DataType="STRING" Constant="false" ExternalAccess="Read/Write">
<Data>05 00 00 00 53 43 52 41 50 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00</Data>
<Data Format="String" Length="5">
'SCRAP'
</Data>
</Tag>