6

私は簡単だと思っていた小さな問題を抱えています...しかし悲しいかな...

いくつかの xml があり、xml:space="preserve"C# を使用してルート要素に追加するだけです。

私はこれを試しました:

var rootElem = xDoc.Root; // XDocument
rootElem.SetAttributeValue("{xml}space", "preserve");

この結果は次のとおりです。

<ProjectDetails xmlns="http://site/ppm" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" p3:space="preserve" xmlns:p3="xml">

これは同等だと思います

<ProjectDetails xmlns="http://site/ppm" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xml:space="preserve">

ただxml:space、特殊な属性なのでちょっと疑問です。

そう:

それらは同一ですか?

これを「きれいな」方法でドキュメントに追加する方法はありますか?

4

1 に答える 1