XmlEntity.PublicId Property
.NET Framework 4.5
Gets the value of the public identifier on the entity declaration.
Namespace: System.Xml
Assembly: System.Xml (in System.Xml.dll)
Property Value
Type: System.StringThe public identifier on the entity. If there is no public identifier, null is returned.
The following example displays information on the entities declared in the XML document.
using System; using System.IO; using System.Xml; public class Sample { private const String filename = "doment.xml"; public static void Main() { XmlDocument doc = new XmlDocument(); doc.Load(filename); Console.WriteLine("Display information on all entities..."); XmlNamedNodeMap nMap = doc.DocumentType.Entities; DisplayEntities(nMap); } public static void DisplayEntities(XmlNamedNodeMap nMap) { for (int i=0; i < nMap.Count; i++) { XmlEntity ent = (XmlEntity) nMap.Item(i); Console.Write("{0} ", ent.NodeType); Console.Write("{0} ", ent.Name); Console.Write("{0} ", ent.NotationName); Console.Write("{0} ", ent.PublicId); Console.Write("{0} ", ent.SystemId); Console.WriteLine(); } } }
The example uses the file, doment.xml, as input.
<!DOCTYPE doc [
<!ELEMENT doc ANY>
<!NOTATION w SYSTEM "wine.exe">
<!NOTATION v PUBLIC "vine.exe">
<!NOTATION jpg PUBLIC "Jpeg picture format">
<!NOTATION gif SYSTEM "Gif picture format">
<!ENTITY wn PUBLIC "http://www.cohowinery.com" "coho.exe" NDATA w>
<!ENTITY vn SYSTEM "http://www.cohovineyard.com" NDATA v>
<!ENTITY mytxt "Text Sample">
<!ATTLIST doc
src ENTITY #IMPLIED
srcs ENTITIES #IMPLIED
jpgPic NOTATION (jpg) #IMPLIED
gifPic NOTATION (gif) #REQUIRED>
]>
<doc jpgPic="jpg" gifPic="gif" srcs="vn wn">
something
</doc>
Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.