3
我有,我认为是一个没有脑子......但可惜有点问题......添加XML:空间根元素
我有一些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
是一个特殊的属性,我有点怀疑。
所以:
它们是否相同?
有没有办法以“干净”的方式将它添加到文档?