XDocumentType Konstruktory

Definice

Inicializuje novou instanci XDocumentType třídy.

Přetížení

XDocumentType(XDocumentType)

Inicializuje instanci třídy z jiného XDocumentType objektuXDocumentType.

XDocumentType(String, String, String, String)

Inicializuje instanci třídy XDocumentType.

XDocumentType(XDocumentType)

Inicializuje instanci třídy z jiného XDocumentType objektuXDocumentType.

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)

Parametry

other
XDocumentType

Objekt XDocumentType , ze který se má kopírovat.

Poznámky

Tento konstruktor se primárně používá interně při vytváření hloubkové kopie stromu XML.

Viz také

Platí pro

XDocumentType(String, String, String, String)

Inicializuje instanci třídy XDocumentType.

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)

Parametry

name
String

A String obsahující kvalifikovaný název DTD, který je stejný jako kvalifikovaný název kořenového prvku dokumentu XML.

publicId
String

A String , který obsahuje veřejný identifikátor externí veřejné DTD.

systemId
String

A String obsahující systémový identifikátor externího privátního DTD.

internalSubset
String

A String obsahující interní podmnožinu pro interní DTD.

Příklady

Následující příklad vytvoří dokument s interní DTD. Při vytváření objektu XDocumentType určuje kvalifikovaný název DTD (Pubs) a řetězec, který obsahuje interní podmnožinu. Vzhledem k tomu, že dokument nepoužívá veřejný nebo privátní externí DTD, publicId je nastaven systemId na null.

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)  

Tento příklad vytvoří následující výstup:

<!--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.-->  

Viz také

Platí pro