XmlDocumentType::Entities Property
.NET Framework (current version)
Gets the collection of XmlEntity nodes declared in the document type declaration.
Assembly: System.Xml (in System.Xml.dll)
Property Value
Type: System.Xml::XmlNamedNodeMap^An XmlNamedNodeMap containing the XmlEntity nodes. The returned XmlNamedNodeMap is read-only.
The order in which the entities are returned is not based on the order in which these items may appear in the document. The order is also not guaranteed to be the same between similar documents, or between different implementations or versions of the class.
The following example displays information about the entities declared in the XML document.
#using <System.Xml.dll> using namespace System; using namespace System::IO; using namespace System::Xml; public ref class Sample { public: static void DisplayEntities( XmlNamedNodeMap^ nMap ) { for ( int i = 0; i < nMap->Count; i++ ) { XmlEntity^ ent = dynamic_cast<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(); } } }; int main() { XmlDocument^ doc = gcnew XmlDocument; doc->Load( "doment.xml" ); Console::WriteLine( "Display information on all entities..." ); XmlNamedNodeMap^ nMap = doc->DocumentType->Entities; Sample^ MySample = gcnew Sample; MySample->DisplayEntities( nMap ); }
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>
.NET Framework
Available since 1.1
Available since 1.1
Show: