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

Dim instance As XmlNode Dim newChild As XmlNode Dim returnValue As XmlNode returnValue = instance.PrependChild(newChild)
戻り値
追加されたノード。


newChild が既にツリーに存在する場合は、最初に削除されます。
別のドキュメントで作成されたノードを挿入する場合は、XmlDocument.ImportNode を使用してそのノードを現在のドキュメントにインポートできます。インポートされたノードは次に、現在のドキュメントに挿入できます。
このメソッドは、DOM (Document Object Model) に対する Microsoft 拡張機能です。
継承時の注意 派生クラスで PrependChild をオーバーライドする場合は、イベントを正常に発生させるために、基本クラスの PrependChild メソッドを呼び出す必要があります。
新しいノードを XML ドキュメントに追加する例を次に示します。
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 genre='novel' ISBN='1-861001-57-5'>" & _ "<title>Pride And Prejudice</title>" & _ "</book>") Dim root As XmlNode = doc.DocumentElement 'Create a new node. Dim elem As XmlElement = doc.CreateElement("price") elem.InnerText = "19.95" 'Add the node to the document. root.PrependChild(elem) Console.WriteLine("Display the modified XML...") doc.Save(Console.Out) 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 genre='novel' ISBN='1-861001-57-5'>" + "<title>Pride And Prejudice</title>" + "</book>"); XmlNode root = doc.DocumentElement; //Create a new node. XmlElement elem = doc.CreateElement("price"); elem.InnerText="19.95"; //Add the node to the document. root.PrependChild(elem); Console.WriteLine("Display the modified XML..."); doc.Save(Console.Out); } }
#using <System.Xml.dll> using namespace System; using namespace System::IO; using namespace System::Xml; int main() { XmlDocument^ doc = gcnew XmlDocument; doc->LoadXml( "<book genre='novel' ISBN='1-861001-57-5'>" "<title>Pride And Prejudice</title>" "</book>" ); XmlNode^ root = doc->DocumentElement; //Create a new node. XmlElement^ elem = doc->CreateElement( "price" ); elem->InnerText = "19.95"; //Add the node to the document. root->PrependChild( elem ); Console::WriteLine( "Display the modified XML..." ); doc->Save( Console::Out ); }
import System.*; import System.IO.*; import System.Xml.*; public class Sample { public static void main(String[] args) { XmlDocument doc = new XmlDocument(); doc.LoadXml("<book genre='novel' ISBN='1-861001-57-5'>" + "<title>Pride And Prejudice</title>" + "</book>"); XmlNode root = doc.get_DocumentElement(); //Create a new node. XmlElement elem = doc.CreateElement("price"); elem.set_InnerText("19.95"); //Add the node to the document. root.PrependChild(elem); Console.WriteLine("Display the modified XML..."); doc.Save(Console.get_Out()); } //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.PrependChild メソッドを検索する場合は、下記のリンクをクリックしてください。

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