XDocumentType Konstruktoren

Definition

Initialisiert eine neue Instanz der XDocumentType-Klasse.

Überlädt

XDocumentType(XDocumentType)

Initialisiert eine Instanz der XDocumentType-Klasse mit einem anderen XDocumentType-Objekt

XDocumentType(String, String, String, String)

Initialisiert eine Instanz der XDocumentType-Klasse.

XDocumentType(XDocumentType)

Source:
XDocumentType.cs
Source:
XDocumentType.cs
Source:
XDocumentType.cs

Initialisiert eine Instanz der XDocumentType-Klasse mit einem anderen XDocumentType-Objekt

public:
 XDocumentType(System::Xml::Linq::XDocumentType ^ other);
public XDocumentType (System.Xml.Linq.XDocumentType other);
new System.Xml.Linq.XDocumentType : System.Xml.Linq.XDocumentType -> System.Xml.Linq.XDocumentType
Public Sub New (other As XDocumentType)

Parameter

other
XDocumentType

Ein XDocumentType-Objekt, aus dem kopiert werden soll.

Hinweise

Dieser Konstruktor wird hauptsächlich intern verwendet, wenn eine tiefe Kopie einer XML-Struktur erstellt wird.

Weitere Informationen

Gilt für:

XDocumentType(String, String, String, String)

Source:
XDocumentType.cs
Source:
XDocumentType.cs
Source:
XDocumentType.cs

Initialisiert eine Instanz der XDocumentType-Klasse.

public:
 XDocumentType(System::String ^ name, System::String ^ publicId, System::String ^ systemId, System::String ^ internalSubset);
public XDocumentType (string name, string publicId, string systemId, string internalSubset);
public XDocumentType (string name, string? publicId, string? systemId, string internalSubset);
public XDocumentType (string name, string? publicId, string? systemId, string? internalSubset);
new System.Xml.Linq.XDocumentType : string * string * string * string -> System.Xml.Linq.XDocumentType
Public Sub New (name As String, publicId As String, systemId As String, internalSubset As String)

Parameter

name
String

Ein String, der den qualifizierten Namen der DTD enthält. Dieser stimmt mit dem qualifizierten Namen des Stammelements des XML-Dokuments überein.

publicId
String

Ein String, der den öffentlichen Bezeichner einer externen öffentlichen DTD enthält.

systemId
String

Ein String, der den Systembezeichner einer externen privaten DTD enthält.

internalSubset
String

Ein String, der die interne Teilmenge für eine interne DTD enthält.

Beispiele

Im folgenden Beispiel wird ein Dokument mit einer internen DTD erstellt. Wenn das XDocumentType -Objekt erstellt wird, gibt es den qualifizierten Namen der DTD (Pubs) und eine Zeichenfolge an, die die interne Teilmenge enthält. Da das Dokument keine öffentliche oder private externe DTD verwendet, werden und publicIdsystemId auf nullfestgelegt.

string internalSubset = @"<!ELEMENT Pubs (Book+)>  
<!ELEMENT Book (Title, Author)>  
<!ELEMENT Title (#PCDATA)>  
<!ELEMENT Author (#PCDATA)>";  

string target = "xml-stylesheet";  
string data = "href=\"mystyle.css\" title=\"Compact\" type=\"text/css\"";  

XDocument doc = new XDocument(  
    new XComment("This is a comment."),  
    new XProcessingInstruction(target, data),  
    new XDocumentType("Pubs", null, null, internalSubset),  
    new XElement("Pubs",   
        new XElement("Book",  
            new XElement("Title", "Artifacts of Roman Civilization"),  
            new XElement("Author", "Moreno, Jordao")  
        ),  
        new XElement("Book",  
            new XElement("Title", "Midieval Tools and Implements"),  
            new XElement("Author", "Gazit, Inbar")  
        )  
    ),  
    new XComment("This is another comment.")  
);  
doc.Declaration = new XDeclaration("1.0", "utf-8", "true");  

Console.WriteLine(doc);  
Dim internalSubset = _  
    "<!ELEMENT Pubs (Book+)>" & Environment.NewLine & _  
    "<!ELEMENT Book (Title, Author)>" & Environment.NewLine & _  
    "<!ELEMENT Title (#PCDATA)>" & Environment.NewLine & _  
    "<!ELEMENT Author (#PCDATA)>"  

Dim doc As XDocument = _  
    <?xml version="1.0" encoding="utf-8" standalone="yes"?>  
    <!--This is a comment.-->  
    <?xml-stylesheet href="mystyle.css" title="Compact" type="text/css"?>  
    <Pubs>  
        <Book>  
            <Title>Artifacts of Roman Civilization</Title>  
            <Author>Moreno, Jordao</Author>  
        </Book>  
        <Book>  
            <Title>Midieval Tools and Implements</Title>  
            <Author>Gazit, Inbar</Author>  
        </Book>  
    </Pubs>  
    <!--This is another comment.-->  

doc.FirstNode.NextNode.AddAfterSelf(new XDocumentType("Pubs", Nothing, Nothing, internalSubset))  

Console.WriteLine(doc)  

Dieses Beispiel erzeugt die folgende Ausgabe:

<!--This is a comment.-->  
<?xml-stylesheet href="mystyle.css" title="Compact" type="text/css"?>  
<!DOCTYPE Pubs [<!ELEMENT Pubs (Book+)>  
<!ELEMENT Book (Title, Author)>  
<!ELEMENT Title (#PCDATA)>  
<!ELEMENT Author (#PCDATA)>]>  
<Pubs>  
  <Book>  
    <Title>Artifacts of Roman Civilization</Title>  
    <Author>Moreno, Jordao</Author>  
  </Book>  
  <Book>  
    <Title>Midieval Tools and Implements</Title>  
    <Author>Gazit, Inbar</Author>  
  </Book>  
</Pubs>  
<!--This is another comment.-->  

Weitere Informationen

Gilt für: