XDocumentType Oluşturucular

Tanım

XDocumentType sınıfının yeni bir örneğini başlatır.

Aşırı Yüklemeler

XDocumentType(XDocumentType)

Sınıfın bir örneğini XDocumentType başka bir XDocumentType nesneden başlatır.

XDocumentType(String, String, String, String)

XDocumentType sınıfının örneğini başlatır.

XDocumentType(XDocumentType)

Kaynak:
XDocumentType.cs
Kaynak:
XDocumentType.cs
Kaynak:
XDocumentType.cs

Sınıfın bir örneğini XDocumentType başka bir XDocumentType nesneden başlatır.

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)

Parametreler

other
XDocumentType

Kopyalanacak XDocumentType nesne.

Açıklamalar

Bu oluşturucu öncelikle bir XML ağacının derin kopyasını oluştururken dahili olarak kullanılır.

Ayrıca bkz.

Şunlara uygulanır

XDocumentType(String, String, String, String)

Kaynak:
XDocumentType.cs
Kaynak:
XDocumentType.cs
Kaynak:
XDocumentType.cs

XDocumentType sınıfının örneğini başlatır.

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)

Parametreler

name
String

String XML belgesinin kök öğesinin tam adıyla aynı olan DTD'nin tam adını içeren bir.

publicId
String

Dış String genel DTD'nin ortak tanımlayıcısını içeren bir.

systemId
String

Dış String özel DTD'nin sistem tanımlayıcısını içeren bir.

internalSubset
String

İç String DTD'nin iç alt kümesini içeren bir.

Örnekler

Aşağıdaki örnek, iç DTD'ye sahip bir belge oluşturur. Nesnesini oluşturduğunda XDocumentType , DTD'nin (Pubs) tam adını ve iç alt kümeyi içeren bir dizeyi belirtir. Belge genel veya özel bir dış DTD kullanmadığından ve publicIdsystemId olarak ayarlanır 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)  

Bu örnek aşağıdaki çıkışı oluşturur:

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

Ayrıca bkz.

Şunlara uygulanır