XmlDocument.CreateAttribute 메서드

정의

지정된 이름을 가진 XmlAttribute를 만듭니다.

오버로드

CreateAttribute(String)

지정된 Name을 가진 XmlAttribute를 만듭니다.

CreateAttribute(String, String)

지정된 정규화된 이름과 NamespaceURI가 있는 XmlAttribute를 만듭니다.

CreateAttribute(String, String, String)

지정된 Prefix, LocalNameNamespaceURI가 있는 XmlAttribute를 만듭니다.

CreateAttribute(String)

지정된 Name을 가진 XmlAttribute를 만듭니다.

public:
 System::Xml::XmlAttribute ^ CreateAttribute(System::String ^ name);
public System.Xml.XmlAttribute CreateAttribute (string name);
member this.CreateAttribute : string -> System.Xml.XmlAttribute
Public Function CreateAttribute (name As String) As XmlAttribute

매개 변수

name
String

특성의 정규화된 이름입니다. 이름에 콜론이 포함되어 있는 경우, Prefix 속성은 첫 번째 콜론 앞의 이름 부분을 반영하고 LocalName 속성은 첫 번째 콜론 뒤의 이름 부분을 반영합니다. 접두사가 xmlns같은 인식된 기본 제공되는 접두사가 아닌 경우 NamespaceURI는 비어 있습니다. 이 경우 NamespaceURIhttp://www.w3.org/2000/xmlns/의 값이 있습니다.

반환

XmlAttribute

XmlAttribute입니다.

예제

다음은 특성을 만들어 XML 문서에 추가합니다.

#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>" );
   
   //Create an attribute.
   XmlAttribute^ attr = doc->CreateAttribute( "publisher" );
   attr->Value = "WorldWide Publishing";
   
   //Add the new node to the document. 
   doc->DocumentElement->SetAttributeNode( attr );
   Console::WriteLine( "Display the modified XML..." );
   doc->Save( Console::Out );
}

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>");

    //Create an attribute.
    XmlAttribute attr = doc.CreateAttribute("publisher");
    attr.Value = "WorldWide Publishing";

    //Add the new node to the document.
    doc.DocumentElement.SetAttributeNode(attr);

    Console.WriteLine("Display the modified XML...");
    doc.Save(Console.Out);
  }
}
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>")
        
        'Create an attribute.
        Dim attr As XmlAttribute = doc.CreateAttribute("publisher")
        attr.Value = "WorldWide Publishing"
        
        'Add the new node to the document. 
        doc.DocumentElement.SetAttributeNode(attr)
        
        Console.WriteLine("Display the modified XML...")
        doc.Save(Console.Out)
    End Sub
End Class

설명

메서드 XmlAttributeXmlElement 사용하여 SetAttributeNode 추가할 수 있습니다.

적용 대상

CreateAttribute(String, String)

지정된 정규화된 이름과 NamespaceURI가 있는 XmlAttribute를 만듭니다.

public:
 System::Xml::XmlAttribute ^ CreateAttribute(System::String ^ qualifiedName, System::String ^ namespaceURI);
public System.Xml.XmlAttribute CreateAttribute (string qualifiedName, string namespaceURI);
public System.Xml.XmlAttribute CreateAttribute (string qualifiedName, string? namespaceURI);
member this.CreateAttribute : string * string -> System.Xml.XmlAttribute
Public Function CreateAttribute (qualifiedName As String, namespaceURI As String) As XmlAttribute

매개 변수

qualifiedName
String

특성의 정규화된 이름입니다. 이름에 콜론이 포함되어 있는 경우, Prefix 속성은 콜론 앞의 이름 부분을 반영하고 LocalName 속성은 콜론 뒤의 이름 부분을 반영합니다.

namespaceURI
String

특성의 네임스페이스 URI입니다. 정규화된 이름에 xmlns 접두사가 포함된 경우 이 매개 변수는 http://www.w3.org/2000/xmlns/이어야 합니다.

반환

XmlAttribute

XmlAttribute입니다.

설명

메서드 XmlAttributeXmlElement 사용하여 SetAttributeNode 추가할 수 있습니다.

적용 대상

CreateAttribute(String, String, String)

지정된 Prefix, LocalNameNamespaceURI가 있는 XmlAttribute를 만듭니다.

public:
 virtual System::Xml::XmlAttribute ^ CreateAttribute(System::String ^ prefix, System::String ^ localName, System::String ^ namespaceURI);
public virtual System.Xml.XmlAttribute CreateAttribute (string prefix, string localName, string namespaceURI);
public virtual System.Xml.XmlAttribute CreateAttribute (string? prefix, string localName, string? namespaceURI);
abstract member CreateAttribute : string * string * string -> System.Xml.XmlAttribute
override this.CreateAttribute : string * string * string -> System.Xml.XmlAttribute
Public Overridable Function CreateAttribute (prefix As String, localName As String, namespaceURI As String) As XmlAttribute

매개 변수

prefix
String

특성의 접두사입니다. String.Empty와 null 은 같습니다.

localName
String

특성의 로컬 이름입니다.

namespaceURI
String

특성의 네임스페이스 URI입니다. String.Empty와 null 은 같습니다. prefix가 xmlns일 경우 이 매개 변수는 http://www.w3.org/2000/xmlns/이어야 합니다. 그렇지 않으면 예외가 throw됩니다.

반환

XmlAttribute

XmlAttribute입니다.

설명

메서드 XmlAttributeXmlElement 사용하여 SetAttributeNode 추가할 수 있습니다.

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

적용 대상