XmlDeclaration::Standalone Property

 

Gets or sets the value of the standalone attribute.

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

public:
property String^ Standalone {
	String^ get();
	void set(String^ value);
}

Property Value

Type: System::String^

Valid values are yes if all entity declarations required by the XML document are contained within the document or no if an external document type definition (DTD) is required. If a standalone attribute is not present in the XML declaration, this property returns String.Empty.

The following example creates an XmlDeclaration node and adds it to an XML document.

#using <System.Xml.dll>

using namespace System;
using namespace System::IO;
using namespace System::Xml;
int main()
{

   // Create and load the XML document.
   XmlDocument^ doc = gcnew XmlDocument;
   String^ xmlString = "<book><title>Oberon's Legacy</title></book>";
   doc->Load( gcnew StringReader( xmlString ) );

   // Create an XML declaration. 
   XmlDeclaration^ xmldecl;
   xmldecl = doc->CreateXmlDeclaration( "1.0", nullptr, nullptr );
   xmldecl->Encoding = "UTF-8";
   xmldecl->Standalone = "yes";

   // Add the new node to the document.
   XmlElement^ root = doc->DocumentElement;
   doc->InsertBefore( xmldecl, root );

   // Display the modified XML document 
   Console::WriteLine( doc->OuterXml );
}

Universal Windows Platform
Available since 10
.NET Framework
Available since 1.1
Return to top
Show: