M. Fawad Surosh M. Fawad Surosh - 1 year ago 109
C# Question

Inject a node inside XmlNode

I have a quick question:

using C#, how can I inject a node inside XmlNode please. I don't want to involve XmlDocument in my specific method.


Answer Source

If you do not want to pass a XmlDocument instance in your method parameter list, then you can get the XmlDocument from the XmlNode instance by the OwnerDocument property.

Like in this example:

public void MyMethod(XmlNode node)
      var newElement = node.OwnerDocument.CreateElement("element");

Hope this helps.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download