如何在XML文件中更改行(Config)

时间:2014-01-20 13:46:36

标签: c# xml file

我需要将第二行更改为config schema ="xxx.xsd"我该怎么做?

1<?xml version="1.0" encoding="utf-8"?>
2<**config**>
3<maketool-config>
.
.
.
</maketool-config>
</config>

这是代码:

 XElement triggerRoot = new XElement("config",
                new XElement("maketool-config",
            );

1 个答案:

答案 0 :(得分:0)

        var doc = new XmlDocument();
        var triggerRoot = new XElement("config", new XElement("maketool-config", ""));
        var newAttribute = doc.CreateAttribute("schema");
        newAttribute.Value = "xxx.xsd";
        triggerRoot.SetAttributeValue("schema", "xxx.xsd");