XmlDeclaration.Standalone Propiedad
Definición
Importante
Parte de la información hace referencia a la versión preliminar del producto, que puede haberse modificado sustancialmente antes de lanzar la versión definitiva. Microsoft no otorga ninguna garantía, explícita o implícita, con respecto a la información proporcionada aquí.
Obtiene o establece el valor del atributo independiente.
public:
property System::String ^ Standalone { System::String ^ get(); void set(System::String ^ value); };
public string Standalone { get; set; }
member this.Standalone : string with get, set
Public Property Standalone As String
Valor de propiedad
Los valores válidos son yes si todas las declaraciones de entidad requeridas por el documento XML están contenidas en el documento o no si se requiere una definición de tipo de documento externo (DTD). Si un atributo independiente no está presente en la declaración XML, esta propiedad devuelve String.Empty.
Ejemplos
En el ejemplo siguiente se crea un XmlDeclaration nodo y se agrega a un documento XML.
using System;
using System.IO;
using System.Xml;
public class Sample {
public static void Main() {
// Create and load the XML document.
XmlDocument doc = new XmlDocument();
string xmlString = "<book><title>Oberon's Legacy</title></book>";
doc.Load(new StringReader(xmlString));
// Create an XML declaration.
XmlDeclaration xmldecl;
xmldecl = doc.CreateXmlDeclaration("1.0",null,null);
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);
}
}
Imports System.IO
Imports System.Xml
public class Sample
public shared sub Main()
' Create and load the XML document.
Dim doc as XmlDocument = new XmlDocument()
Dim xmlString as string = "<book><title>Oberon's Legacy</title></book>"
doc.Load(new StringReader(xmlString))
' Create an XML declaration.
Dim xmldecl as XmlDeclaration
xmldecl = doc.CreateXmlDeclaration("1.0",nothing, nothing)
xmldecl.Encoding="UTF-8"
xmldecl.Standalone="yes"
' Add the new node to the document.
Dim root as XmlElement = doc.DocumentElement
doc.InsertBefore(xmldecl, root)
' Display the modified XML document
Console.WriteLine(doc.OuterXml)
end sub
end class