たとえば、XMLドキュメントがあります
<document>
<attribute id = 1 />
<attribute id = 2 />
<attribute id = 3 />
<attribute id = 4 />
<attribute id = 5 />
<attribute id = 6 />
</document>
C++コードで DOM パーサーを使用して XML ファイルを解析しています。id = 3 などの特定の属性を削除しています。
Xerces ライブラリの API を使用して属性を削除しましたが、属性を削除した場所に空白行が表示されます。
削除は次のように行います。指定されたファイルから必要な属性を削除し、残りの内容を一時ファイルにコピーしますが、空白行が作成されます。
<document>
<attribute id = 1 />
<attribute id = 2 />
<attribute id = 4 />
<attribute id = 5 />
<attribute id = 6 />
</document>
次のような出力が必要です。削除後にファイルに空白行が存在しないようにする必要があります
<document>
<attribute id = 1 />
<attribute id = 2 />
<attribute id = 4 />
<attribute id = 5 />
<attribute id = 6 />
</document>