XmlElement.WriteTo(XmlWriter) 메서드

정의

현재 노드를 지정된 XmlWriter에 저장합니다.

public:
 override void WriteTo(System::Xml::XmlWriter ^ w);
public override void WriteTo (System.Xml.XmlWriter w);
override this.WriteTo : System.Xml.XmlWriter -> unit
Public Overrides Sub WriteTo (w As XmlWriter)

매개 변수

w
XmlWriter

저장할 대상 XmlWriter입니다.

예제

다음 예제에서는 요소에 특성을 추가한 다음 수정된 요소를 표시합니다.

#using <System.Xml.dll>

using namespace System;
using namespace System::IO;
using namespace System::Xml;
int main()
{
   XmlDocument^ doc = gcnew XmlDocument;
   doc->LoadXml( "<book xmlns:bk='urn:samples' bk:ISBN='1-861001-57-5'><title>Pride And Prejudice</title></book>" );
   XmlElement^ root = doc->DocumentElement;
   
   // Add a new attribute.
   root->SetAttribute( "genre", "urn:samples", "novel" );
   Console::WriteLine( "Display the modified XML..." );
   XmlTextWriter^ writer = gcnew XmlTextWriter( Console::Out );
   writer->Formatting = Formatting::Indented;
   root->WriteTo( writer );
}
using System;
using System.IO;
using System.Xml;

public class Sample
{
  public static void Main()
  {

    XmlDocument doc = new XmlDocument();
    doc.LoadXml("<book xmlns:bk='urn:samples' bk:ISBN='1-861001-57-5'>" +
                "<title>Pride And Prejudice</title>" +
                "</book>");

    XmlElement root = doc.DocumentElement;

    // Add a new attribute.
    root.SetAttribute("genre", "urn:samples", "novel");

    Console.WriteLine("Display the modified XML...");
    XmlTextWriter writer = new XmlTextWriter(Console.Out);
    writer.Formatting = Formatting.Indented;
    root.WriteTo(writer);
  }
}
Imports System.IO
Imports System.Xml

public class Sample

  public shared sub Main()

    Dim doc as XmlDocument = new XmlDocument()
    doc.LoadXml("<book xmlns:bk='urn:samples' bk:ISBN='1-861001-57-5'>" & _
                "<title>Pride And Prejudice</title>" & _
                "</book>")

    Dim root as XmlElement = doc.DocumentElement

    ' Add a new attribute.
    root.SetAttribute("genre", "urn:samples", "novel")

    Console.WriteLine("Display the modified XML...")
    Dim writer as XmlTextWriter = new XmlTextWriter(Console.Out)
    writer.Formatting = Formatting.Indented
    root.WriteTo(writer)

  end sub
end class

설명

이 메서드는 DOM(문서 개체 모델)에 대한 Microsoft 확장입니다.

적용 대상