C# XmlDocument不';不保存字符实体
我目前正在阅读一个带有C# XmlDocument不';不保存字符实体,c#,xml,character,xmldocument,entities,C#,Xml,Character,Xmldocument,Entities,我目前正在阅读一个带有Xmldocument的xml文件,并编写一些值。我正在阅读的部分如下所示: <para styleclass="Normal" style="margin-top:12px; line-height:1.0; tabstops:none;"><table rowcount="22" colcount="4" style="width:100%; cell-padding:1px; cell-spacing:2px; page-break-inside:a
Xmldocument
的xml文件,并编写一些值。我正在阅读的部分如下所示:
<para styleclass="Normal" style="margin-top:12px; line-height:1.0; tabstops:none;"><table rowcount="22" colcount="4" style="width:100%; cell-padding:1px; cell-spacing:2px; page-break-inside:auto; border-width:0px; border-spacing:2px; cell-border-width:0px; border-style:none; background-color:none; head-row-background-color:none; alt-row-background-color:none;">
<tr style="vertical-align:top">
<td style="vertical-align:bottom; width:33%; background-color:#dddddd;">
<para><text styleclass="Normal" style="font-size:9pt; font-weight:bold; vertical-align:baseline; color:#000000;" translate="true"> </text></para>
</td>
<td style="vertical-align:bottom; width:22%; background-color:#dddddd;">
<para style="text-align:center;"><text styleclass="Normal" style="font-size:9pt; font-weight:bold; vertical-align:baseline; color:#000000;" translate="true">Windows 32</text></para>
</td>
<td style="vertical-align:bottom; width:22%; background-color:#dddddd;">
<para style="text-align:center;"><text styleclass="Normal" style="font-size:9pt; font-weight:bold; vertical-align:baseline; color:#000000;" translate="true">Windows 64</text></para>
</td>
<td style="vertical-align:bottom; width:22%; background-color:#dddddd;">
<para style="text-align:center;"><text styleclass="Normal" style="font-size:9pt; font-weight:bold; vertical-align:baseline; color:#000000;" translate="true">Linux</text></para>
</td>
</tr>
<tr style="vertical-align:top">
<td style="vertical-align:bottom; background-color:#dddddd;">
<para><text styleclass="Normal" style="font-size:9pt; font-weight:bold; vertical-align:baseline; color:#000000;" translate="true">SomeDll.dll</text></para>
</td>
<td style="width:22%;">
<para style="text-align:center;"><text styleclass="Normal" style="font-size:9pt; vertical-align:baseline; color:#000000;" translate="true">1.0.4.78</text></para>
</td>
<td style="width:22%;">
<para style="text-align:center;"><text styleclass="Normal" style="font-size:9pt; vertical-align:baseline; color:#000000;" translate="true">1.0.4.77</text></para>
</td>
<td style="width:22%;">
<para style="text-align:center;"><text styleclass="Normal" style="font-size:9pt; vertical-align:baseline; color:#000000;" translate="true">to be defined</text></para>
</td>
</tr>
视窗32
视窗64
Linux
SomeDll.dll
1.0.4.78
1.0.4.77
待定义
如您所见,在第二段中有一个字符实体( 2;)。我不编辑它,只是浏览一下。完成编辑后,我使用.save
方法保存文件
问题是,字符实体被保存到它所表示的位置,在本例中是一个空格“”。如果我现在在程序中再次打开xml文件,我会得到一个异常,因为该值为null。有没有办法将字符实体保存到它们的实体形式中?鉴于识别哪些实体被转换的困难(例如,示例中有许多空格),将它们转换回来将非常困难 如果您修改加载程序以允许实体被转换的实例,可能会更容易。可能的实体重复