0
私はC#の簡単なツールをコーディングして、特定のXMLファイルの属性を変更しています。期待通りの変更を実行するためにenvolved すべてのコーディングが働いているが、それは私には、以下の問題が発生したファイルを保存するために来るとき、 ソースXMLファイルは、以下のような特定のidentがあります。保存した後C#特定のident設定をXmlWriterSettingsに設定する
<AAL2Bearer id="0" method="create">
<attributes>
<pathId>16</pathId>
<vccId>VCC/2</vccId></attributes></AAL2Bearer>
<AAL2Bearer id="1" method="create">
<attributes>
<pathId>8</pathId>
<vccId>VCC/3</vccId></attributes></AAL2Bearer>
<AAL2Bearer id="2" method="create">
<attributes>
<pathId>1</pathId>
<vccId>VCC/5</vccId></attributes></AAL2Bearer>
私のXMLファイルをそれは:
<AAL2Bearer id="0" method="create">
<attributes>
<pathId>16</pathId>
<vccId>VCC/2</vccId>
</attributes>
</AAL2Bearer>
<AAL2Bearer id="1" method="create">
<attributes>
<pathId>8</pathId>
<vccId>VCC/3</vccId>
</attributes>
</AAL2Bearer>
<AAL2Bearer id="2" method="create">
<attributes>
<pathId>1</pathId>
<vccId>VCC/5</vccId>
</attributes>
</AAL2Bearer>
私が試してみました:ノーIDENTのあるXMLファイルを持つことができるよこのスニペットでは
var settings = new XmlWriterSettings();
settings.Indent = true;
settings.IndentChars = "";
しかし、私が必要としている各行の始まりです。同じ行のxmlノードを閉じる必要があります。基本的には新しいxmlノードに新しい行を追加するだけですが、XMLノードとその親を常に同じ行に閉じます。
おかげに関して
パーサが文句を言わないノードが閉鎖され、その上にラインを気に
、なぜそれが重要ではない –
それは私がアップロードしていますどこにとして問題ありませんこのタイプのidentが適用されていない場合、変更されたxmlはファイルを拒否します。 –
あなたは正しいAlex Kです。それはBOMでした。私の間違いのために申し訳ありません:( –