C# で軽量エディターを作成していますが、文字列を適切にフォーマットされた XML 文字列に変換するための最良の方法を知りたいです。「public bool FormatAsXml(string text, out stringformattedXmlText)」のようなパブリック メソッドが C# ライブラリにあることを願っていますが、それほど簡単ではありません。
非常に具体的には、以下の出力を生成するメソッド「SomeMethod」は何でしょうか?
string unformattedXml;
string formattedXml;
unformattedXml = "<?xml version=\"1.0\"?><book><author>Lewis, C.S.</author><title>The Four Loves</title></book>"
formattedXml = SomeMethod(unformattedXml);
Console.WriteLine(formattedXml);
出力:
<?xml version="1.0"?>
<book id="123">
<author>Lewis, C.S.</author>
<title>The Four Loves</title>
</book>