XmlDataDocument.CloneNode メソッドとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > XmlDataDocument.CloneNode メソッドの意味・解説 

XmlDataDocument.CloneNode メソッド

現在のノード複製作成します

名前空間: System.Xml
アセンブリ: System.Data (system.data.dll 内)
構文構文

Public Overrides Function
 CloneNode ( _
    deep As Boolean _
) As XmlNode
Dim instance As XmlDataDocument
Dim deep As Boolean
Dim returnValue As XmlNode

returnValue = instance.CloneNode(deep)
public override XmlNode CloneNode (
    bool deep
)
public:
virtual XmlNode^ CloneNode (
    bool deep
) override
public XmlNode CloneNode (
    boolean deep
)
public override function CloneNode (
    deep : boolean
) : XmlNode

パラメータ

deep

指定したノードの下にあるサブツリーのクローン順次作成していく場合true指定したノードだけのクローン作成する場合false

戻り値
クローンとして作成されノード

解説解説
使用例使用例

DataSetXmlDataDocument読み込みXmlDataDocument簡易クローン作成する例を次に示します

この例では、SQL Server 2000 Northwind データベース使用してます。

Imports System
Imports System.Xml
Imports System.Data
Imports System.Data.SqlClient
 
 
public class Sample
 
  public shared sub Main()
   
    Dim dsNorthwind as DataSet = new
 DataSet()
 
    'Create the connection string.
    Dim sConnect as String
           
    sConnect="Data Source=localhost;Integrated Security=SSPI;Initial
 Catalog=Northwind"     
          
    'Create a connection object to connect to the northwind db.
    Dim nwconnect as SqlConnection
    nwconnect = new SqlConnection(sConnect)
 
    'Create a command string to select all the customers in the WA region.
    Dim sCommand as String
 = "Select * from Customers where Region='WA'"
 
    'Create an Adapter to load the DataSet.
    Dim myDataAdapter as SqlDataAdapter
    myDataAdapter = new SqlDataAdapter(sCommand, nwconnect)
 
    'Fill the DataSet with the selected records.
    myDataAdapter.Fill(dsNorthwind, "Customers")
 
    'Load the document with the DataSet.
    Dim doc as XmlDataDocument = new
 XmlDataDocument(dsNorthwind)  
 
    'Create a shallow clone of the XmlDataDocument. Note that although
    'none of the child nodes were copied over, the cloned node does
    'have the schema information.
    Dim clone as XmlDataDocument
    clone = CType (doc.CloneNode(false), XmlDataDocument) 
    Console.WriteLine("Child count: {0}", clone.ChildNodes.Count)
    Console.WriteLine(clone.DataSet.GetXmlSchema())
 
  end sub
end class
using System;
using System.Data;
using System.Xml;
using System.Data.SqlClient;

public class Sample
{
  public static void Main()
  {
     DataSet dsNorthwind = new DataSet();

     //Create the connection string.           
     String sConnect;
     sConnect="Data Source=localhost;Integrated Security=SSPI;Initial Catalog=Northwind";
     
         
     //Create a connection object to connect to the northwind db.
     SqlConnection nwconnect = new SqlConnection(sConnect);

     //Create a command string to select all the customers in the WA
 region.
     String sCommand = "Select * from Customers where Region='WA'";

     //Create an adapter to load the DataSet.
     SqlDataAdapter myDataAdapter = new SqlDataAdapter(sCommand,
 nwconnect);

     //Fill the DataSet with the selected records.
     myDataAdapter.Fill(dsNorthwind,"Customers");

     //Load the document with the DataSet.
     XmlDataDocument doc = new XmlDataDocument(dsNorthwind); 
  

     //Create a shallow clone of the XmlDataDocument. Note that although
     //none of the child nodes were copied over, the cloned node does
     //have the schema information.
     XmlDataDocument clone = (XmlDataDocument) doc.CloneNode(false);
     Console.WriteLine("Child count: {0}", clone.ChildNodes.Count);
     Console.WriteLine(clone.DataSet.GetXmlSchema());   
  }
}
#using <System.Xml.dll>
#using <System.Transactions.dll>
#using <System.EnterpriseServices.dll>
#using <System.dll>
#using <System.Data.dll>

using namespace System;
using namespace System::Data;
using namespace System::Xml;
using namespace System::Data::SqlClient;
int main()
{
   DataSet^ dsNorthwind = gcnew DataSet;
   
   //Create the connection string.           
   String^ sConnect;
   sConnect = "Data Source=localhost;Integrated Security=SSPI;Initial Catalog=Northwind";
   
   //Create a connection object to connect to the northwind db.
   SqlConnection^ nwconnect = gcnew SqlConnection( sConnect );
   
   //Create a command string to select all the customers in the WA region.
   String^ sCommand = "Select * from Customers where Region='WA'";
   
   //Create an adapter to load the DataSet.
   SqlDataAdapter^ myDataAdapter = gcnew SqlDataAdapter( sCommand,nwconnect );
   
   //Fill the DataSet with the selected records.
   myDataAdapter->Fill( dsNorthwind, "Customers" );
   
   //Load the document with the DataSet.
   XmlDataDocument^ doc = gcnew XmlDataDocument( dsNorthwind );
   
   //Create a shallow clone of the XmlDataDocument. Note that although
   //none of the child nodes were copied over, the cloned node does
   //have the schema information.
   XmlDataDocument^ clone = dynamic_cast<XmlDataDocument^>(doc->CloneNode(
 false ));
   Console::WriteLine( "Child count: {0}", clone->ChildNodes->Count
 );
   Console::WriteLine( clone->DataSet->GetXmlSchema() );
}

import System.*;
import System.Data.*;
import System.Xml.*;
import System.Data.SqlClient.*;

public class Sample
{
    public static void main(String[]
 args)
    {
        DataSet dsNorthwind = new DataSet();

        //Create the connection string.           
        String sConnect;
        sConnect = "Data Source=localhost;Integrated Security=SSPI;"
            + "Initial Catalog=Northwind";

        //Create a connection object to connect to the northwind db.
        SqlConnection nwConnect = new SqlConnection(sConnect);

        //Create a command string to select all the customers in the WA
 region.
        String sCommand = "Select * from Customers where Region='WA'";

        //Create an adapter to load the DataSet.
        SqlDataAdapter myDataAdapter = new SqlDataAdapter(sCommand,
 nwConnect);

        //Fill the DataSet with the selected records.
        myDataAdapter.Fill(dsNorthwind, "Customers");

        //Load the document with the DataSet.
        XmlDataDocument doc = new XmlDataDocument(dsNorthwind);

        //Create a shallow clone of the XmlDataDocument. Note that although
        //none of the child nodes were copied over, the cloned node
 does
        //have the schema information.
        XmlDataDocument clone = (XmlDataDocument)doc.CloneNode(false);
        Console.WriteLine("Child count: {0}", 
            System.Convert.ToString(clone.get_ChildNodes().get_Count()));
        Console.WriteLine(clone.get_DataSet().GetXmlSchema());
    } //main
} //Sample
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照


このページでは「.NET Framework クラス ライブラリ リファレンス」からXmlDataDocument.CloneNode メソッドを検索した結果を表示しています。
Weblioに収録されているすべての辞書からXmlDataDocument.CloneNode メソッドを検索する場合は、下記のリンクをクリックしてください。
 全ての辞書からXmlDataDocument.CloneNode メソッド を検索

英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

XmlDataDocument.CloneNode メソッドのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



XmlDataDocument.CloneNode メソッドのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2025 Microsoft.All rights reserved.

©2025 GRAS Group, Inc.RSS