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

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

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

Imports System Imports System.IO Imports System.Xml public class Sample public shared sub Main() ' Create the XmlDocument. Dim doc as XmlDocument = new XmlDocument() doc.LoadXml("<items/>") ' Create a document fragment. Dim docFrag as XmlDocumentFragment = doc.CreateDocumentFragment() ' Set the contents of the document fragment. docFrag.InnerXml ="<item>widget</item>" ' Create a deep clone. The cloned node ' includes child nodes. Dim deep as XmlNode = docFrag.CloneNode(true) Console.WriteLine("Name: " + deep.Name) Console.WriteLine("OuterXml: " + deep.OuterXml) ' Create a shallow clone. The cloned node does ' not include any child nodes. Dim shallow as XmlNode = docFrag.CloneNode(false) Console.WriteLine("Name: " + shallow.Name) Console.WriteLine("OuterXml: " + shallow.OuterXml) end sub end class
using System; using System.IO; using System.Xml; public class Sample { public static void Main() { // Create the XmlDocument. XmlDocument doc = new XmlDocument(); doc.LoadXml("<items/>"); // Create a document fragment. XmlDocumentFragment docFrag = doc.CreateDocumentFragment(); // Set the contents of the document fragment. docFrag.InnerXml ="<item>widget</item>"; // Create a deep clone. The cloned node // includes child nodes. XmlNode deep = docFrag.CloneNode(true); Console.WriteLine("Name: " + deep.Name); Console.WriteLine("OuterXml: " + deep.OuterXml); // Create a shallow clone. The cloned node does // not include any child nodes. XmlNode shallow = docFrag.CloneNode(false); Console.WriteLine("Name: " + shallow.Name); Console.WriteLine("OuterXml: " + shallow.OuterXml); } }
#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( "<items/>" ); // Create a document fragment. XmlDocumentFragment^ docFrag = doc->CreateDocumentFragment(); // Set the contents of the document fragment. docFrag->InnerXml = "<item>widget</item>"; // Create a deep clone. The cloned node // includes child nodes. XmlNode^ deep = docFrag->CloneNode( true ); Console::WriteLine( "Name: {0}", deep->Name ); Console::WriteLine( "OuterXml: {0}", deep->OuterXml ); // Create a shallow clone. The cloned node does // not include any child nodes. XmlNode^ shallow = docFrag->CloneNode( false ); Console::WriteLine( "Name: {0}", shallow->Name ); Console::WriteLine( "OuterXml: {0}", shallow->OuterXml ); }
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("<items/>"); // Create a document fragment. XmlDocumentFragment docFrag = doc.CreateDocumentFragment(); // Set the contents of the document fragment. docFrag.set_InnerXml("<item>widget</item>"); // Create a deep clone. The cloned node // includes child nodes. XmlNode deep = docFrag.CloneNode(true); Console.WriteLine("Name: " + deep.get_Name()); Console.WriteLine("OuterXml: " + deep.get_OuterXml()); // Create a shallow clone. The cloned node does // not include any child nodes. XmlNode shallow = docFrag.CloneNode(false); Console.WriteLine("Name: " + shallow.get_Name()); Console.WriteLine("OuterXml: " + 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に収録されているすべての辞書からXmlDocumentFragment.CloneNode メソッドを検索する場合は、下記のリンクをクリックしてください。

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