Namespace XmlTest Sub TestMain() ' 一時ディレクトリを取得 Dim tempDir = GetExclusiveTempDirPath( "XmlTest" ) Dim doc = New System.Xml.XmlDocument() doc.AppendChild( doc.CreateXmlDeclaration( "1.0", "shift-jis", Nothing ) ) doc.AppendChild( doc.CreateElement( "root" ) ) doc.ChildNodes[1].AppendChild( doc.CreateElement( "test" ) ) Dim attr1 = doc.CreateAttribute( "attr1" ) attr1.Value = "123" doc.ChildNodes[1].Attributes.Add( attr1 ) Dim attr2 = doc.CreateAttribute( "attr2" ) attr2.Value = "456" doc.ChildNodes[1].Attributes.Add( attr2 ) ' 書いて doc.Save( tempDir + "\test.xml" ) ' 読んで Dim clone = New System.Xml.XmlDocument clone.Load( tempDir + "\test.xml" ) ' 比較してみる UnitTest( "XmlTest", doc.OuterXml = clone.OuterXml ) End Sub End Namespace XmlTest.TestMain()