XmlRootAttribute.IsNullable プロパティ
アセンブリ: System.Xml (system.xml.dll 内)

Dim instance As XmlRootAttribute Dim value As Boolean value = instance.IsNullable instance.IsNullable = value
/** @property */ public boolean get_IsNullable () /** @property */ public void set_IsNullable (boolean value)
XmlSerializer が xsi:nil 属性を生成する場合は true。それ以外の場合は false。

XML スキーマで構造を指定することにより、XML ドキュメントで、要素の内容が欠落していることを明示的に知らせることができます。このような要素には、true に設定された属性 xsi:nil が含まれます。詳細については、W3C の Web サイト (http://www.w3.org/TR/xmlschema-1/) で仕様『XML Schema Part 1: Structures』を参照してください。
IsNullable プロパティが true に設定されている場合は、次の XML の例で示すように、xsi:nil 属性が生成されます。

Group というクラスをシリアル化する例を次に示します。この例では、XmlRootAttribute をクラスに適用し、IsNullable プロパティを false に設定します。
Imports System Imports System.IO Imports System.Xml.Serialization Imports System.Xml ' Apply the XmlRootAttribute and set the IsNullable property to false. <XmlRoot(IsNullable := False)> _ Public Class Group Public Name As String End Class Public Class Run Public Shared Sub Main() Console.WriteLine("Running") Dim test As New Run() test.SerializeObject("NullDoc.xml") End Sub Public Sub SerializeObject(ByVal filename As String) Dim s As New XmlSerializer(GetType(Group)) ' Writing the file requires a TextWriter. Dim writer As New StreamWriter(filename) ' Create the object to serialize. Dim mygroup As Group = Nothing ' Serialize the object, and close the TextWriter. s.Serialize(writer, mygroup) writer.Close() End Sub End Class
using System; using System.IO; using System.Xml.Serialization; using System.Xml; // Apply the XmlRootAttribute and set the IsNullable property to false. [XmlRoot(IsNullable = false)] public class Group { public string Name; } public class Run { public static void Main() { Console.WriteLine("Running"); Run test = new Run(); test.SerializeObject("NullDoc.xml"); } public void SerializeObject(string filename) { XmlSerializer s = new XmlSerializer(typeof(Group)); // Writing the file requires a TextWriter. TextWriter writer = new StreamWriter(filename); // Create the object to serialize. Group mygroup = null; // Serialize the object, and close the TextWriter. s.Serialize(writer, mygroup); writer.Close(); } }
#using <System.Xml.dll> #using <System.dll> using namespace System; using namespace System::IO; using namespace System::Xml::Serialization; using namespace System::Xml; // Apply the XmlRootAttribute and set the IsNullable property to false. [XmlRoot(IsNullable=false)] public ref class Group { public: String^ Name; }; void SerializeObject( String^ filename ) { XmlSerializer^ s = gcnew XmlSerializer( Group::typeid ); // Writing the file requires a TextWriter. TextWriter^ writer = gcnew StreamWriter( filename ); // Create the object to serialize. Group^ mygroup = nullptr; // Serialize the object, and close the TextWriter. s->Serialize( writer, mygroup ); writer->Close(); } int main() { Console::WriteLine( "Running" ); SerializeObject( "NullDoc.xml" ); }
import System.*; import System.IO.*; import System.Xml.Serialization.*; import System.Xml.*; // Apply the XmlRootAttribute and set the IsNullable property to false. /** @attribute XmlRoot(IsNullable = false) */ public class Group { public String name; } //Group public class Run { public static void main(String[] args) { Console.WriteLine("Running"); Run test = new Run(); test.SerializeObject("NullDoc.xml"); } //main public void SerializeObject(String fileName) { XmlSerializer s = new XmlSerializer(Group.class.ToType()); // Writing the file requires a TextWriter. TextWriter writer = new StreamWriter(fileName); // Create the object to serialize. Group myGroup = null; // Serialize the object, and close the TextWriter. s.Serialize(writer, myGroup); writer.Close(); } //SerializeObject } //Run

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Weblioに収録されているすべての辞書からXmlRootAttribute.IsNullable プロパティを検索する場合は、下記のリンクをクリックしてください。

- XmlRootAttribute.IsNullable プロパティのページへのリンク