Ho un XML (questo è esattamente quello che sembra):come cambiare nodo XML valori
<PolicyChangeSet schemaVersion="2.1" username="" description="">
<Attachment name="" contentType="">
<Description/>
<Location></Location>
</Attachment>
</PolicyChangeSet>
Questo è in macchina dell'utente.
Devo aggiungere valori a ciascun nodo: nome utente, descrizione, nome allegato, tipo di contenuto e posizione.
Questo è quello che ho finora:
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);
Qualsiasi aiuto?
che ha funzionato :) ... posso solo accettare la tua risposta in 10 minuti tho. grazie Jan! – Testifier
come aggiungerei comunque un valore per "posizione"? è solo tra lo <>> ... ?? – Testifier
Anytime :) Osserva la proprietà 'InnerText' di XmlNode. – Jan