Hi,
I don't see 'SetAttric=bute' in the intellisense list, however inspite of
that if i add the code specified by you and compile the project I get the
following error - System.xml.xmlnode does not contain a definition for
setattribute. Should I add any assembly reference(I am using VS 1.1)
Thanks in advance.
"Oleg Tkachenko" <ol***@multiconn.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
Anita C wrote:
How can I add an attribute (called tag) to a node that I've added to an
xml document using the CreateElement method.
My code is as follows:
XmlDocument doc1 = new XmlDocument();
XmlDeclaration dec = doc1.CreateXmlDeclaration("1.0", "", "yes");
doc1.PrependChild ( dec );
XmlNode cont = doc1.CreateElement("Container");
XmlElement cont = doc1.CreateElement("Container");
cont.SetAttribute("tag", "foo");
doc1.AppendChild(cont);
--
Oleg Tkachenko
http://www.tkachenko.com/blog
Multiconn Technologies, Israel