SystemId Property
Collapse the table of content
Expand the table of content

XDocumentType.SystemId Property


Gets or sets the system identifier for this Document Type Definition (DTD).

Namespace:   System.Xml.Linq
Assembly:  System.Xml.Linq (in System.Xml.Linq.dll)

Public Property SystemId As String

Property Value

Type: System.String

A String that contains the system identifier for this Document Type Definition (DTD).

If an XML document uses an external private DTD, this property will contain the private identifier of the external DTD.

The following example creates an XML document that refers to an external private DTD. The DTD does not have an internal subset. The call to the XDocumentType constructor reflects the use of the external private DTD. It passes null for the internal subset.

                Dim pubsDtd As String = _ 
    "<!ELEMENT Pubs (Book+)>" & Environment.NewLine & _
    "<!ELEMENT Book (Title, Author)>" & Environment.NewLine & _
    "<!ELEMENT Title (#PCDATA)>" & Environment.NewLine & _
    "<!ELEMENT Author (#PCDATA)>"
File.WriteAllText("Pubs.dtd", pubsDtd)

Dim target As String = "xml-stylesheet"
Dim data As String = "href='mystyle.css' title='Compact' type='text/css'"

Dim doc As XDocument = _
    <?xml version='1.0'?>
            <Title>Artifacts of Roman Civilization</Title>
            <Author>Moreno, Jordao</Author>
            <Title>Midieval Tools and Implements</Title>
            <Author>Gazit, Inbar</Author>
    <!--This is another comment.-->

doc _
.FirstNode _
.AddBeforeSelf(New XDocumentType("Pubs", Nothing, "Pubs.dtd", Nothing))

doc.Declaration = New XDeclaration("1.0", "utf-8", "true")

' Validate Pubs.xml against Pubs.dtd.
Dim xrs As XmlReaderSettings = New XmlReaderSettings()
xrs.ProhibitDtd = False
xrs.ValidationType = ValidationType.DTD
xrs.ConformanceLevel = ConformanceLevel.Auto
Dim xr As XmlReader = XmlReader.Create("Pubs.xml", xrs)
Dim doc2 As XDocument = XDocument.Load(xr)

Dim dt As XDocumentType = doc2.Document.DocumentType
Console.WriteLine("SystemId:{0}", dt.SystemId)

This example produces the following output:


Universal Windows Platform
Available since 8
.NET Framework
Available since 3.5
Portable Class Library
Supported in: portable .NET platforms
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Windows Phone
Available since 8.1
Return to top
© 2016 Microsoft