The imported System.Xml.XmlNode.
The returned node has no parent. The source node is not altered or removed from the original document; ImportNode creates a copy of the source node.
Importing a node creates an XmlNode object owned by the importing document, with XmlNode.Name and XmlNode.NodeType identical to the source node. The new object also has the attributes related to namespaces (XmlNode.Prefix, XmlNode.LocalName, and XmlNode.NamespaceURI).
Depending on the node type of the imported node and the value of the deep parameter, additional information is copied as appropriate. This method attempts to mirror the behavior expected if a fragment of XML or HTML source was copied from one document to another (recognizing that, in the XML case, the two documents could have different DTDs).
The following table describes the specific behavior for each System.Xml.XmlNodeType.
Attribute |
The XmlAttribute.Specified property is set to true on the generated System.Xml.XmlAttribute. The descendants of the source XmlAttribute are recursively imported and the resulting nodes reassembled to form the corresponding subtree. |
The deep parameter does not apply to XmlAttribute nodes; they always carry their children with them when imported. |
CData |
Copies the node, including its data. |
Copies the node, including its data. |
Comment |
Copies the node, including its data. |
Copies the node, including its data. |
DocumentFragment |
The descendants of the source node are recursively imported and the resulting nodes reassembled to form the corresponding subtree. |
An empty System.Xml.XmlDocumentFragment is generated. |
DocumentType |
Copies the node, including its data.* |
Copies the node, including its data.* |
Element |
The descendants of the source element and its specified attribute nodes are recursively imported and the resulting nodes reassembled to form the corresponding subtree. Note: Default attributes are not copied. If the document being imported into defines default attributes for this element name, those are assigned. |
Specified attribute nodes of the source element are imported, and the generated XmlAttribute nodes are attached to the generated System.Xml.XmlElement. Note: Default attributes are not copied. If the document being imported into defines default attributes for this element name, those are assigned. |
EntityReference |
Because the source and destination documents could have the entities defined differently, this method only copies the System.Xml.XmlEntityReference node. The replacement text is not included. If the destination document has the entity defined, its value is assigned. |
Because the source and destination documents could have the entities defined differently, this method only copies the System.Xml.XmlEntityReference node. The replacement text is not included. If the destination document has the entity defined, its value is assigned. |
ProcessingInstruction |
Copies the target and data value from the imported node. |
Copies the target and data value from the imported node. |
Text |
Copies the node, including its data. |
Copies the node, including its data. |
SignificantWhitespace |
Copies the node, including its data. |
Copies the node, including its data. |
Whitespace |
Copies the node, including its data. |
Copies the node, including its data. |
XmlDeclaration |
Copies the target and data value from the imported node. |
Copies the target and data value from the imported node. |
All other node types. |
These node types cannot be imported. |
These node types cannot be imported. |
*Although DocumentType nodes can be imported, a document can only have one DocumentType. If the document currently has a DocumenType node, it must be removed before adding a new one.