I assume that you need an element with the value "Tom and Jerry", and that's fine.
It is part of the XML syntax that you cannot have a space in the name of an element or attribute.
Possible method:
XmlElement child = doc.CreateElement("cartoon"); child.InnerText = "Tom and Jerry";
which produces
<cartoon>Tom and Jerry</cartoon>
Also, check out XDocument when you can. Much easier than XmlDocument.
XElement child = new XElement("cartoon", "Tom and Jerry");
source share