XDocumentType Construtores

Definição

Inicializa uma nova instância da classe XDocumentType.Initializes a new instance of the XDocumentType class.

Sobrecargas

XDocumentType(XDocumentType)

Inicializa uma instância da classe XDocumentType com base em outro objeto XDocumentType.Initializes an instance of the XDocumentType class from another XDocumentType object.

XDocumentType(String, String, String, String)

Inicializa uma instância da classe XDocumentType.Initializes an instance of the XDocumentType class.

XDocumentType(XDocumentType)

Inicializa uma instância da classe XDocumentType com base em outro objeto XDocumentType.Initializes an instance of the XDocumentType class from another XDocumentType object.

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)

Parâmetros

other
XDocumentType

Um objeto XDocumentType do qual copiar.An XDocumentType object to copy from.

Comentários

Esse construtor é usado principalmente internamente ao fazer uma cópia profunda de uma árvore XML.This constructor is primarily used internally when making a deep copy of an XML tree.

Aplica-se a

XDocumentType(String, String, String, String)

Inicializa uma instância da classe XDocumentType.Initializes an instance of the XDocumentType class.

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

Parâmetros

name
String

Um String que contém o nome qualificado do DTD, que é o mesmo que o nome qualificado do elemento raiz do documento XML.A String that contains the qualified name of the DTD, which is the same as the qualified name of the root element of the XML document.

publicId
String

Um String que contém o identificador público de DTD público externo.A String that contains the public identifier of an external public DTD.

systemId
String

Um String que contém o identificador do sistema de um DTD privado externo.A String that contains the system identifier of an external private DTD.

internalSubset
String

Um String que contém o subconjunto interno para um DTD interno.A String that contains the internal subset for an internal DTD.

Exemplos

O exemplo a seguir cria um documento com um DTD interno.The following example creates a document with an internal DTD. Quando ele cria o XDocumentType objeto, ele especifica o nome qualificado do DTD (pubs) e uma cadeia de caracteres que contém o subconjunto interno.When it creates the XDocumentType object, it specifies the qualified name of the DTD (Pubs), and a string that contains the internal subset. Como o documento não usa um DTD externo público ou privado, o publicId e o systemId são definidos como null .Because the document does not use a public or private external DTD, the publicId and systemId are set to 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)  

Esse exemplo gera a saída a seguir:This example produces the following output:

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

Aplica-se a