Wednesday, September 19, 2007

Creating or adding an attribute (xmlAttribute) on a node in c# and Visual Studio 2003

 

 

 

//Add attribute id2
XmlDocument xDocId2 = new XmlDocument();                               
xDocId2.Load (tmpFilename);           
foreach (XmlNode unNodo in xDocId2.DocumentElement.GetElementsByTagName("nodo") )
{
    XmlAttribute nAttr;
    nAttr =  xDocId2.CreateAttribute ("id2");   
    nAttr.Value= unNodo.Attributes["id"].Value     ;
    unNodo.Attributes.Append( nAttr);
}
xDocId2.Save(tmpFilename);

3 Comments:

Anonymous stevej6x7 said...

Thanks,

Very helpful!

Steve

2:47 PM

 
Anonymous Vicentiu said...

Thank you!

5:56 AM

 
Anonymous LuizM said...

Obrigado! Foi muito Ăștil!

5:08 AM

 

Post a Comment

<< Home