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



既定では、LoadXml メソッドは空白も有意な空白も保存しません。
このメソッドは、DTD 検証またはスキーマ検証を実行しません。検証を実行する場合は、Load メソッドを使用し、そのメソッドに XmlValidatingReader を渡します。読み込み時検証の例については、「XmlDocument」を参照してください。
このメソッドは、DOM (Document Object Model) に対する Microsoft 拡張機能です。

XML を XmlDocument オブジェクトに読み込み、ファイルに保存する例を次に示します。
Imports System Imports System.Xml public class Sample public shared sub Main() ' Create the XmlDocument. Dim doc as XmlDocument = new XmlDocument() doc.LoadXml("<item><name>wrench</name></item>") ' Add a price element. Dim newElem as XmlElement = doc.CreateElement("price") newElem.InnerText = "10.95" doc.DocumentElement.AppendChild(newElem) ' Save the document to a file and auto-indent the output. Dim writer as XmlTextWriter = new XmlTextWriter("data.xml",nothing) writer.Formatting = Formatting.Indented doc.Save(writer) end sub end class
using System; using System.Xml; public class Sample { public static void Main() { // Create the XmlDocument. XmlDocument doc = new XmlDocument(); doc.LoadXml("<item><name>wrench</name></item>"); // Add a price element. XmlElement newElem = doc.CreateElement("price"); newElem.InnerText = "10.95"; doc.DocumentElement.AppendChild(newElem); // Save the document to a file and auto-indent the output. XmlTextWriter writer = new XmlTextWriter("data.xml" ,null); writer.Formatting = Formatting.Indented; doc.Save(writer); } }
#using <System.Xml.dll> using namespace System; using namespace System::Xml; int main() { // Create the XmlDocument. XmlDocument^ doc = gcnew XmlDocument; doc->LoadXml( "<item><name>wrench</name></item>" ); // Add a price element. XmlElement^ newElem = doc->CreateElement( "price" ); newElem->InnerText = "10.95"; doc->DocumentElement->AppendChild( newElem ); // Save the document to a file and auto-indent the output. XmlTextWriter^ writer = gcnew XmlTextWriter( "data.xml", nullptr ); writer->Formatting = Formatting::Indented; doc->Save( writer ); }
import System.*; import System.Xml.*; public class Sample { public static void main(String[] args) { // Create the XmlDocument. XmlDocument doc = new XmlDocument(); doc.LoadXml("<item><name>wrench</name></item>"); // Add a price element. XmlElement newElem = doc.CreateElement("price"); newElem.set_InnerText("10.95"); doc.get_DocumentElement().AppendChild(newElem); // Save the document to a file and auto-indent the output. XmlTextWriter writer = new XmlTextWriter("data.xml", null); writer.set_Formatting(Formatting.Indented); doc.Save(writer); } //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.LoadXml メソッドを検索する場合は、下記のリンクをクリックしてください。

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