XmlDocument.CloneNode メソッド
アセンブリ: System.Xml (system.xml.dll 内)

Dim instance As XmlDocument Dim deep As Boolean Dim returnValue As XmlNode returnValue = instance.CloneNode(deep)
戻り値
クローンとして作成された XmlDocument ノード。

このメソッドは、ノードのコピー コンストラクタとして機能します。クローンとして作成されたノードには親がありません。ParentNode は null 参照 (Visual Basic では Nothing) を返します。
deep が true の場合、クローンとして作成されたノードにはすべての子ノードが含まれます。それ以外の場合は、XmlDocument ノードだけがクローンとして作成されます。このメソッドが他のノード型でどのように動作するかを確認するには、XmlNode.CloneNode メソッドのトピックを参照してください。

Option Explicit Option Strict Imports System Imports System.IO Imports System.Xml Public Class Sample Public Shared Sub Main() 'Create the XmlDocument. Dim doc As New XmlDocument() doc.LoadXml("<book genre='novel' ISBN='1-861001-57-5'>" & _ "<title>Pride And Prejudice</title>" & _ "</book>") 'Create a deep clone. The cloned node 'includes the child node. Dim deep As XmlDocument = CType(doc.CloneNode(True), XmlDocument) Console.WriteLine(deep.ChildNodes.Count) 'Create a shallow clone. The cloned node does not 'include the child node. Dim shallow As XmlDocument = CType(doc.CloneNode(False), XmlDocument) Console.WriteLine(shallow.Name + shallow.OuterXml) Console.WriteLine(shallow.ChildNodes.Count) End Sub 'Main End Class 'Sample
using System; using System.IO; using System.Xml; public class Sample { public static void Main() { //Create the XmlDocument. XmlDocument doc = new XmlDocument(); doc.LoadXml("<book genre='novel' ISBN='1-861001-57-5'>" + "<title>Pride And Prejudice</title>" + "</book>"); //Create a deep clone. The cloned node //includes the child node. XmlDocument deep = (XmlDocument) doc.CloneNode(true); Console.WriteLine(deep.ChildNodes.Count); //Create a shallow clone. The cloned node does not //include the child node. XmlDocument shallow = (XmlDocument) doc.CloneNode(false); Console.WriteLine(shallow.Name + shallow.OuterXml); Console.WriteLine(shallow.ChildNodes.Count); } }
#using <System.Xml.dll> using namespace System; using namespace System::IO; using namespace System::Xml; int main() { //Create the XmlDocument. XmlDocument^ doc = gcnew XmlDocument; doc->LoadXml( "<book genre='novel' ISBN='1-861001-57-5'><title>Pride And Prejudice</title></book>" ); //Create a deep clone. The cloned node //includes the child node. XmlDocument^ deep = dynamic_cast<XmlDocument^>(doc->CloneNode( true )); Console::WriteLine( deep->ChildNodes->Count ); //Create a shallow clone. The cloned node does not //include the child node. XmlDocument^ shallow = dynamic_cast<XmlDocument^>(doc->CloneNode( false )); Console::WriteLine( "{0}{1}", shallow->Name, shallow->OuterXml ); Console::WriteLine( shallow->ChildNodes->Count ); }
import System.*; import System.IO.*; import System.Xml.*; public class Sample { public static void main(String[] args) { //Create the XmlDocument. XmlDocument doc = new XmlDocument(); doc.LoadXml(("<book genre='novel' ISBN='1-861001-57-5'>" + "<title>Pride And Prejudice</title>" + "</book>")); //Create a deep clone. The cloned node //includes the child node. XmlDocument deep = (XmlDocument)doc.CloneNode(true); Console.WriteLine(deep.get_ChildNodes().get_Count()); //Create a shallow clone. The cloned node does not //include the child node. XmlDocument shallow = (XmlDocument)doc.CloneNode(false); Console.WriteLine(shallow.get_Name() + shallow.get_OuterXml()); Console.WriteLine(shallow.get_ChildNodes().get_Count()); } //main } //Sample

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Weblioに収録されているすべての辞書からXmlDocument.CloneNode メソッドを検索する場合は、下記のリンクをクリックしてください。

- XmlDocument.CloneNode メソッドのページへのリンク