Search code examples
c#xmlxmldocumentcreateelement

Why is CreateElement() a member function of XmlDocument class?


XmlDocument xmlDoc = new XmlDocument();         
XmlElement elem = xmlDoc.CreateElement("Elem");
xmlDoc.AppendChild(elem);

AppendChild() is doing some changes to the object referred by xmldoc.... it makes sense it is a member function

CreateElement() which looks more like a common function to all the objects.... why is it a member function() ?


Solution

  • The CreateElement method probably creates a new XmlElement using the XmlElement constuctor, which requires an XmlDocument as one of the constructor params.