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

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


このメソッドは、ノードのコピー コンストラクタとして機能します。複製されたノードには親がありません。ParentNode は null 参照 (Visual Basic では Nothing) を返します。
各 XmlNodeType の固有の動作を次の表に示します。

Option Explicit Option Strict Imports System Imports System.IO Imports System.Xml Public Class Sample Public Shared Sub Main() Dim doc As New XmlDocument() doc.LoadXml("<book ISBN='1-861001-57-5'>" & _ "<title>Pride And Prejudice</title>" & _ "<price>19.95</price>" & _ "</book>") Dim root As XmlNode = doc.FirstChild 'Create a deep clone. The cloned node 'includes the child nodes. Dim deep As XmlNode = root.CloneNode(True) Console.WriteLine(deep.OuterXml) 'Create a shallow clone. The cloned node does not 'include the child nodes, but does include its attribute. Dim shallow As XmlNode = root.CloneNode(False) Console.WriteLine(shallow.OuterXml) End Sub 'Main End Class 'Sample
using System; using System.IO; using System.Xml; public class Sample { public static void Main() { XmlDocument doc = new XmlDocument(); doc.LoadXml("<book ISBN='1-861001-57-5'>" + "<title>Pride And Prejudice</title>" + "<price>19.95</price>" + "</book>"); XmlNode root = doc.FirstChild; //Create a deep clone. The cloned node //includes the child nodes. XmlNode deep = root.CloneNode(true); Console.WriteLine(deep.OuterXml); //Create a shallow clone. The cloned node does not //include the child nodes, but does include its attribute. XmlNode shallow = root.CloneNode(false); Console.WriteLine(shallow.OuterXml); } }
#using <System.Xml.dll> using namespace System; using namespace System::IO; using namespace System::Xml; int main() { XmlDocument^ doc = gcnew XmlDocument; doc->LoadXml( "<book ISBN='1-861001-57-5'>" "<title>Pride And Prejudice</title>" "<price>19.95</price>" "</book>" ); XmlNode^ root = doc->FirstChild; //Create a deep clone. The cloned node //includes the child nodes. XmlNode^ deep = root->CloneNode( true ); Console::WriteLine( deep->OuterXml ); //Create a shallow clone. The cloned node does not //include the child nodes, but does include its attribute. XmlNode^ shallow = root->CloneNode( false ); Console::WriteLine( shallow->OuterXml ); }
import System.*; import System.IO.*; import System.Xml.*; public class Sample { public static void main(String[] args) { XmlDocument doc = new XmlDocument(); doc.LoadXml("<book ISBN='1-861001-57-5'>" + "<title>Pride And Prejudice</title>" + "<price>19.95</price>" + "</book>"); XmlNode root = doc.get_FirstChild(); //Create a deep clone. The cloned node //includes the child nodes. XmlNode deep = root.CloneNode(true); Console.WriteLine(deep.get_OuterXml()); //Create a shallow clone. The cloned node does not //include the child nodes, but does include its attribute. XmlNode shallow = root.CloneNode(false); Console.WriteLine(shallow.get_OuterXml()); } //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に収録されているすべての辞書からXmlNode.CloneNode メソッドを検索する場合は、下記のリンクをクリックしてください。

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