Brett, you create attribute nodes just like element nodes. Here's the code
from the link you posted, modified to create the XML in your original post:
XmlDocument xmldoc;
XmlAttribute attr;
XmlElement elem;
XmlElement root;
xmldoc=new XmlDocument();
//let's add the XML declaration section
XmlNode xmlnode=xmldoc.CreateNode(XmlNodeType.XmlDeclarati on,"","");
xmldoc.AppendChild(xmlnode);
//let's add the root element
elem=xmldoc.CreateElement("ROOT");
xmldoc.AppendChild(elem);
root = elem;
//add person elements. assume you have some data structure called ListOfIds
containing the numbers
foreach (int personId in ListOfIds)
{
elem = xmldoc.CreateElement("Person");
attr = xmldoc.CreateAttribute("PersonId");
attr.InnerText = personId.ToString();
elem.Attributes.Append(attr)
root.AppendChild(elem);
}
--
Kai Brinkmann [MSFT]
Please do not send e-mail directly to this alias. This alias is for
newsgroup purposes only.
This posting is provided "AS IS" with no warranties, and confers no rights.
"Brett Romero" <ac*****@cygen.com> wrote in message
news:11*********************@g14g2000cwa.googlegro ups.com...
This pretty much covers the creation part:
http://www.csharphelp.com/archives/archive199.html. Still not sure how
to get the two backslashes in there.
Brett