【发布时间】:2023-01-03 13:25:08
【问题描述】:
我很想删除每个不包含特定值的父母,例如
<drawableDictionary>l_njdocklod12</drawableDictionary>
下面的 XML 示例:
<?xml version="1.0" encoding="UTF-8"?>
<CMapTypes name="lodetnjdock_wh1">
<extensions />
<archetypes>
<Item type="CBaseArchetypeDef">
<lodDist value="550" />
<flags value="0" />
<specialAttribute value="0" />
<bbMin x="-12.3383" y="-6.42445" z="-13.3852" />
<bbMax x="12.3382" y="6.42445" z="13.3852" />
<bsCentre x="-5.05447E-05" y="2.38419E-06" z="0" />
<bsRadius value="19.3046" />
<hdTextureDist value="0" />
<name>hash_349C91C8</name>
<textureDictionary>njdocklod04</textureDictionary>
<clipDictionary />
<drawableDictionary>lodnjdocksuper11_grp</drawableDictionary>
<physicsDictionary>nj_docks</physicsDictionary>
<assetType>ASSET_TYPE_DRAWABLEDICTIONARY</assetType>
<assetName>hash_349C91C8</assetName>
<extensions />
</Item>
<Item type="CBaseArchetypeDef">
<lodDist value="550" />
<flags value="0" />
<specialAttribute value="0" />
<bbMin x="-5.6393" y="-5.45088" z="-4.9861" />
<bbMax x="5.6393" y="5.45088" z="4.9861" />
<bsCentre x="0" y="-4.76837E-07" z="4.76837E-07" />
<bsRadius value="9.29382" />
<hdTextureDist value="0" />
<name>hash_46EE366B</name>
<textureDictionary>njdocklod12</textureDictionary>
<clipDictionary />
<drawableDictionary>l_njdocklod12</drawableDictionary>
<physicsDictionary>nj_docks</physicsDictionary>
<assetType>ASSET_TYPE_DRAWABLEDICTIONARY</assetType>
<assetName>hash_46EE366B</assetName>
<extensions />
</Item>
<Item type="CBaseArchetypeDef">
<lodDist value="550" />
<flags value="0" />
<specialAttribute value="0" />
<bbMin x="-11.8993" y="-34.8797" z="-4.27972" />
<bbMax x="11.8992" y="34.8796" z="4.29434" />
<bsCentre x="-2.76566E-05" y="-1.52588E-05" z="0.0073123" />
<bsRadius value="37.102" />
<hdTextureDist value="0" />
<name>hash_52EAB9C8</name>
<textureDictionary>njdocklod10</textureDictionary>
<clipDictionary />
<drawableDictionary>lodnjdocksuper05_grp</drawableDictionary>
<physicsDictionary>nj_docks</physicsDictionary>
<assetType>ASSET_TYPE_DRAWABLEDICTIONARY</assetType>
<assetName>hash_52EAB9C8</assetName>
<extensions />
</Item>
</archetypes>
<name>nj_docks_lod</name>
<dependencies />
<compositeEntityTypes itemType="CCompositeEntityType" />
</CMapTypes>
期望的结果
<?xml version="1.0" encoding="UTF-8"?>
<CMapTypes name="lodetnjdock_wh1">
<extensions />
<archetypes>
<Item type="CBaseArchetypeDef">
<lodDist value="550" />
<flags value="0" />
<specialAttribute value="0" />
<bbMin x="-5.6393" y="-5.45088" z="-4.9861" />
<bbMax x="5.6393" y="5.45088" z="4.9861" />
<bsCentre x="0" y="-4.76837E-07" z="4.76837E-07" />
<bsRadius value="9.29382" />
<hdTextureDist value="0" />
<name>hash_46EE366B</name>
<textureDictionary>njdocklod12</textureDictionary>
<clipDictionary />
<drawableDictionary>l_njdocklod12</drawableDictionary>
<physicsDictionary>nj_docks</physicsDictionary>
<assetType>ASSET_TYPE_DRAWABLEDICTIONARY</assetType>
<assetName>hash_46EE366B</assetName>
<extensions />
</Item>
</archetypes>
<name>nj_docks_lod</name>
<dependencies />
<compositeEntityTypes itemType="CCompositeEntityType" />
</CMapTypes>
我想实现这个使用正则表达式,使用 Notepad++,因为我离这里的舒适区很远,到目前为止这对我有用。
【问题讨论】:
-
Notepad++ 不是修改 XML 的正确工具。使用应该存在于您最喜欢的脚本语言中的解析器。
-
但是它确实在很多情况下会修改xml,这正是我现在所需要的。如果我有最喜欢的脚本语言,我就不会在这里寻求帮助。