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

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

XmlDocument.LoadXml メソッド

指定した文字列から XML ドキュメント読み込みます。

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

例外例外
例外種類条件

XmlException

XML 内に読み込みエラーまたは解析エラーあります。この場合ドキュメントは空のままです。

解説解説

既定では、LoadXml メソッド空白有意な空白保存しません。

このメソッドは、DTD 検証またはスキーマ検証実行しません。検証実行する場合は、Load メソッド使用し、そのメソッドに XmlValidatingReader を渡します読み込み検証例については、「XmlDocument」を参照してください

このメソッドは、DOM (Document Object Model) に対すMicrosoft 拡張機能です。

使用例使用例

XMLXmlDocument オブジェクト読み込みファイル保存する例を次に示します

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
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
XmlDocument クラス
XmlDocument メンバ
System.Xml 名前空間
PreserveWhitespace



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

辞書ショートカット

すべての辞書の索引

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

   

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



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

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

©2024 GRAS Group, Inc.RSS