so ändern Sie die XML-node-Werte

Ich habe eine XML (das ist genau das, was so wie es aussieht):

<PolicyChangeSet schemaVersion="2.1" username="" description="">
    <Attachment name="" contentType="">
        <Description/>
        <Location></Location>
    </Attachment>
</PolicyChangeSet>

Dies ist auf der Maschine des Benutzers.

Muss ich hinzufügen, Werte für jeden Knoten: username, Beschreibung, name der Anlage, contenttype und Lage.

Dies ist, was ich habe, so weit:

string newValue = string.Empty;
            XmlDocument xmlDoc = new XmlDocument();

            xmlDoc.Load(filePath);
            XmlNode node = xmlDoc.SelectSingleNode("/PolicyChangeSet");
            node.Attributes["username"].Value = AppVars.Username;
            node.Attributes["description"].Value = "Adding new .tiff image.";
            node.Attributes["name"].Value = "POLICY";
            node.Attributes["contentType"].Value = "content Typeeee";

            //node.Attributes["location"].InnerText = "zzz";

            xmlDoc.Save(filePath);

Hilfe?

InformationsquelleAutor Rj. | 2012-08-10
Schreibe einen Kommentar