I am creating XML with C#. I want to append item
to content
. I create an XmlNode with CreateItem
, but I can't seem to append it to the contentElement
.
XmlDocument doc = new XmlDocument();
XmlNode contentElement = doc.CreateElement("content");
doc.AppendChild(contentElement);
contentElement.AppendChild(CreateItem);
public XmlNode CreateItem(XmlDocument doc, string hint, string type, string title, string value) {
XmlNode item = doc.CreateElement("item");
XmlAttribute Hint = doc.CreateAttribute("Hint");
Hint.Value = hint;
XmlAttribute Type = doc.CreateAttribute("Type");
Type.Value = type;
item.Attributes.Append(Hint);
item.Attributes.Append(Type);
XmlNode tit = doc.CreateElement("Title");
tit.InnerText = title;
item.AppendChild(tit);
XmlNode val = doc.CreateElement("Value");
val.InnerText = value;
item.AppendChild(val);
return item;
}