XmlDocument.CreateProcessingInstruction(String, String) XmlDocument.CreateProcessingInstruction(String, String) XmlDocument.CreateProcessingInstruction(String, String) XmlDocument.CreateProcessingInstruction(String, String) Method

정의

지정된 이름과 데이터가 있는 XmlProcessingInstruction을 만듭니다.Creates an XmlProcessingInstruction with the specified name and data.

public:
 virtual System::Xml::XmlProcessingInstruction ^ CreateProcessingInstruction(System::String ^ target, System::String ^ data);
public virtual System.Xml.XmlProcessingInstruction CreateProcessingInstruction (string target, string data);
abstract member CreateProcessingInstruction : string * string -> System.Xml.XmlProcessingInstruction
override this.CreateProcessingInstruction : string * string -> System.Xml.XmlProcessingInstruction
Public Overridable Function CreateProcessingInstruction (target As String, data As String) As XmlProcessingInstruction

매개 변수

target
String String String String

처리 명령의 이름입니다.The name of the processing instruction.

data
String String String String

처리 명령의 데이터입니다.The data for the processing instruction.

반환

XmlProcessingInstruction입니다.The new XmlProcessingInstruction.

예제

다음 예제에서는 ProcessingInstruction 노드를 만들어 문서에 추가 합니다.The following example creates a ProcessingInstruction node and adds it to the document.

#using <System.Xml.dll>

using namespace System;
using namespace System::IO;
using namespace System::Xml;
int main()
{
   XmlDocument^ doc = gcnew XmlDocument;
   
   // Create a procesing instruction.
   XmlProcessingInstruction^ newPI;
   String^ PItext = "type='text/xsl' href='book.xsl'";
   newPI = doc->CreateProcessingInstruction( "xml-stylesheet", PItext );
   
   // Display the target and data information.
   Console::WriteLine( "<?{0} {1}?>", newPI->Target, newPI->Data );
   
   // Add the processing instruction node to the document.
   doc->AppendChild( newPI );
}

using System;
using System.IO;
using System.Xml;

public class Sample
{
  public static void Main()
  {
    XmlDocument doc = new XmlDocument();

    // Create a procesing instruction.
    XmlProcessingInstruction newPI;
    String PItext = "type='text/xsl' href='book.xsl'";
    newPI = doc.CreateProcessingInstruction("xml-stylesheet", PItext);

    // Display the target and data information.
    Console.WriteLine("<?{0} {1}?>", newPI.Target, newPI.Data);

    // Add the processing instruction node to the document.
    doc.AppendChild(newPI);

  }
}
Imports System.IO
Imports System.Xml

public class Sample

  public shared sub Main()
  
    Dim doc as XmlDocument = new XmlDocument()

    ' Create a procesing instruction.
    Dim newPI as XmlProcessingInstruction 
    Dim PItext as String = "type='text/xsl' href='book.xsl'"
    newPI = doc.CreateProcessingInstruction("xml-stylesheet", PItext)

    ' Display the target and data information.
    Console.WriteLine("<?{0} {1}?>", newPI.Target, newPI.Data)

    ' Add the processing instruction node to the document.
    doc.AppendChild(newPI)

  end sub
end class

설명

이 메서드가 문서의 컨텍스트에서 새 개체를 만들고, 있지만 추가 되지 않습니다 자동으로 새 개체를 문서 트리에입니다.Although this method creates the new object in the context of the document, it does not automatically add the new object to the document tree. 새 개체를 추가 하려면 명시적으로 노드 삽입 메서드 중 하나가 호출 해야 합니다.To add the new object, you must explicitly call one of the node insert methods.

W3C XML(Extensible Markup Language) (XML) 1.0 권장 사항에 따라 EntityReference 노드가 특성 노드의 자식이 아닌 경우에만 ProcessingInstruction 노드가 Document, Element 및 EntityReference 노드 내에서 허용 됩니다.According to the W3C Extensible Markup Language (XML) 1.0 recommendation, ProcessingInstruction nodes are only allowed within Document, Element, and EntityReference nodes, when the EntityReference node is not a child of an Attribute node.

적용 대상