スタンドアロン属性の値を取得または設定します。
Public Property Standalone As String
[C#]
public string Standalone {get; set;}
[C++]
public: __property String* get_Standalone();public: __property void set_Standalone(String*);
[JScript]
public function get Standalone() : String;public function set Standalone(String);
プロパティ値
XML ドキュメントで必要なすべてのエンティティ宣言がドキュメント内に格納されている場合、有効値は Yes です。外部の DTD が必要な場合は No です。XML 宣言内にスタンドアロン属性が存在しない場合、このプロパティは String.Empty を返します。
使用例
[Visual Basic, C#, C++] XmlDeclaration ノードを作成し、XML ドキュメントに追加する例を次に示します。
Imports System
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
[C#]
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);
}
}
[C++]
#using <mscorlib.dll>
#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 = new XmlDocument();
String* xmlString = S"<book><title>Oberon's Legacy</title></book>";
doc->Load(new StringReader(xmlString));
// Create an XML declaration.
XmlDeclaration* xmldecl;
xmldecl = doc->CreateXmlDeclaration(S"1.0",0,0);
xmldecl->Encoding=S"UTF-8";
xmldecl->Standalone=S"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);
}
[JScript] JScript のサンプルはありません。Visual Basic、C#、および C++ のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン をクリックします。
必要条件
プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ, .NET Compact Framework - Windows CE .NET