Sample
static void Main(string[] args)
{
System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
doc.LoadXml("<item>Pink Ale Beer</item>");
doc.DocumentElement.SetAttribute("id", "301");
System.Console.WriteLine(doc.DocumentElement.OuterXml);
}
Hope this helps,
Randy
http://www.kbcafe.com
"Peter" <(E-Mail Removed)> wrote in message news:<f79b01c3bddf$8f26d7b0$(E-Mail Removed)>...
> Hi,
> If I use the following code, there is a attribute.
> XmlDocument doc = new XmlDocument();
> doc.LoadXml("<item id='301'>Pink Ale Beer</item>");
>
> If I code the 2nd line as below:
> doc.LoadXml("<item>Pink Ale Beer</item>");
> My question is how to add the attribute after that.
> Please advice. Thanks.
> Peter