NGWS SDK Documentation  

This is preliminary documentation and subject to change.
To comment on this topic, please send us email at ngwssdk@microsoft.com. Thanks!

XmlDocument.ImportNode

Imports a node from another document to this document.

[Visual Basic]
Overridable Public Function ImportNode( _
   ByVal node As XmlNode, _
   ByVal deep As Boolean _
) As XmlNode
[C#]
public virtual XmlNode ImportNode(
   XmlNode node,
   bool deep
);
[C++]
public: virtual XmlNode* ImportNode(
   XmlNode* node,
   bool deep
);
[JScript]
public function ImportNode(
   node : XmlNode,
   deep : Boolean
) : XmlNode;

Parameters

node
[To be supplied.]
deep
true to perform a deep clone; otherwise, false.

Return Value

The imported XmlNode.

Remarks

The returned node has no parent; The source node is not altered or removed from the original document; this method creates a new copy of the source node. For all nodes, importing a node creates a node object owned by the importing document, with attribute values identical to the source node's nodeName and nodeType, plus the attributes related to namespaces (prefix, localName, and namespaceURI). Additional information is copied as appropriate to the nodeType, attempting to mirror the behavior expected if a fragment of XML or HTML source was copied from one document to another, recognizing that the two documents may have different DTDs in the XML case.

The following list describes the specifics for every type of node.

XmlNodeType Description
Attribute The specified flag is set to true on the generated XmlAttribute. The descendants of the source XmlAttribute are recursively imported and the resulting nodes reassembled to form the corresponding subtree. Note that the deep parameter does not apply to XmlAttribute nodes; they always carry their children with them when imported.
DocumentFragment If the deep option was set true, the descendants of the source element will be recursively imported and the resulting nodes reassembled to form the corresponding subtree. Otherwise, this simply generates an empty XmlDocumentFragment.
Document Document nodes cannot be imported.
DocumentType DocumentType nodes cannot be imported.
Element Specified attribute nodes of the source element are imported, and the generated XmlAttribute nodes are attached to the generated XmlElement. Default attributes are not copied, though if the document being imported into defines default attributes for this element name, those are assigned. If the deep parameter was set to true, the descendants of the source element will be recursively imported and the resulting nodes reassembled to form the corresponding subtree.
Entity Entity nodes can be imported, however in the current release of the DOM the DocumentType is readonly. Ability to add these imported nodes to a DocumentType will be considered for addition to a future release of the DOM. On import, the publicId, systemId, and notationName properties are copied. If a deep import is requested, the descendants of the the source Entity is recursively imported and the resulting nodes reassembled to form the corresponding subtree.
EntityReference Only the XmlEntityReference itself is copied, even if a deep import is requested, since the source and destination documents might have defined the entity differently. If the document being imported into provides a definition for this entity name, its value is assigned.
Notation Notation nodes can be imported, however in the current release of the DOM the DocumentType is readonly. Ability to add these imported nodes to a DocumentType will be considered for addition to a future release of the DOM. On import, the publicId and systemId attributes are copied. Note that the deep parameter does not apply to Notation nodes since they never have any children.
ProcessingInstruction The imported node copies its target and data values from those of the source node.
Text, CData, Comment These three types of nodes inheriting from CharacterData copy their data and length properties from those of the source node.

See Also

XmlDocument Class | XmlDocument Members | System.NewXml Namespace