[402] | 1 | Namespace System
|
---|
| 2 | Namespace Xml
|
---|
| 3 |
|
---|
| 4 | /*!
|
---|
| 5 | @brief XMLドキュメントを表す
|
---|
| 6 | */
|
---|
| 7 | Class XmlDocument
|
---|
| 8 | Inherits XmlNode
|
---|
[424] | 9 |
|
---|
| 10 | Sub VerifyLocalName( name As String )
|
---|
| 11 | If Object.ReferenceEquals( name, Nothing ) Then
|
---|
| 12 | ' Throw System.ArgumentException()
|
---|
| 13 | ElseIf name.Length = 0 Then
|
---|
| 14 | ' Throw System.ArgumentException()
|
---|
| 15 | End If
|
---|
| 16 | End Sub
|
---|
| 17 |
|
---|
[402] | 18 | Public
|
---|
| 19 |
|
---|
| 20 | /*!
|
---|
| 21 | @brief コンストラクタ
|
---|
| 22 | */
|
---|
| 23 | Sub XmlDocument()
|
---|
[442] | 24 | XmlNode( XmlNodeType.Document, "", "#document", "", Nothing )
|
---|
[402] | 25 | End Sub
|
---|
| 26 |
|
---|
| 27 | /*!
|
---|
| 28 | @brief コンストラクタ
|
---|
| 29 | */
|
---|
| 30 | 'Sub XmlDocument( xmlImplementation As XmlImplementation )
|
---|
| 31 | 'End Sub
|
---|
| 32 |
|
---|
| 33 | /*!
|
---|
| 34 | @brief コンストラクタ
|
---|
| 35 | */
|
---|
| 36 | 'Sub XmlDocument( xmlNameTable As XmlNameTable )
|
---|
| 37 | 'End Sub
|
---|
| 38 |
|
---|
[451] | 39 |
|
---|
| 40 | '----------------------------------------------------------------
|
---|
| 41 | ' パブリック プロパティ
|
---|
| 42 | '----------------------------------------------------------------
|
---|
| 43 |
|
---|
[424] | 44 | /*!
|
---|
[451] | 45 | @brief このノードとそのすべての子ノードを表すマークアップを取得します。
|
---|
| 46 | @return このノードとそのすべての子ノードを格納しているマークアップ。
|
---|
| 47 | */
|
---|
| 48 | Override Function OuterXml() As String
|
---|
| 49 | Return This.InnerXml
|
---|
| 50 | End Function
|
---|
| 51 |
|
---|
| 52 |
|
---|
| 53 | '----------------------------------------------------------------
|
---|
| 54 | ' パブリック メソッド
|
---|
| 55 | '----------------------------------------------------------------
|
---|
| 56 |
|
---|
| 57 | /*!
|
---|
[424] | 58 | @brief 指定した値を使用して、XmlDeclaration ノードを作成します。
|
---|
[443] | 59 | @param version XMLのバージョン番号。
|
---|
| 60 | encoding 文字コード。(例:"shift-jis", "UTF-8", "EUC-JP")
|
---|
| 61 | standalone 外部DTDの参照が必要かどうか。"yes" or "no"
|
---|
[424] | 62 | */
|
---|
| 63 | Function CreateXmlDeclaration( version As String, encoding As String, standalone As String ) As XmlDeclaration
|
---|
| 64 | Return New XmlDeclaration( version ,encoding, standalone, This )
|
---|
[402] | 65 | End Function
|
---|
| 66 |
|
---|
[424] | 67 | /*!
|
---|
[443] | 68 | @brief 指定した名前を使用して属性を作成します。
|
---|
| 69 | @param name 属性名
|
---|
| 70 | */
|
---|
| 71 | Function CreateAttribute( name As String) As XmlAttribute
|
---|
| 72 | VerifyLocalName( name )
|
---|
| 73 |
|
---|
| 74 | Return New XmlAttribute( "", name, "", This )
|
---|
| 75 | End Function
|
---|
| 76 |
|
---|
| 77 | /*!
|
---|
[424] | 78 | @brief 指定した名前を使用して要素を作成します。
|
---|
[443] | 79 | @param name 要素名。
|
---|
[424] | 80 | */
|
---|
| 81 | Function CreateElement( name As String ) As XmlElement
|
---|
| 82 | VerifyLocalName( name )
|
---|
| 83 |
|
---|
| 84 | Return New XmlElement( "", name, "", This )
|
---|
[402] | 85 | End Function
|
---|
| 86 |
|
---|
[424] | 87 | /*!
|
---|
[451] | 88 | @brief 指定した文字列を使用してテキストノードを作成します。
|
---|
| 89 | @param text 文字列。
|
---|
[424] | 90 | */
|
---|
[451] | 91 | Function CreateTextNode( text As String ) As XmlText
|
---|
| 92 | Return New XmlText( text, This )
|
---|
[424] | 93 | End Function
|
---|
| 94 |
|
---|
[451] | 95 | /*!
|
---|
[452] | 96 | @brief 指定したストリームからXML文書を読み込む。
|
---|
[655] | 97 | @param reader 読み込むリーダ。
|
---|
| 98 | */
|
---|
| 99 | Virtual Sub Load( reader As System.IO.TextReader )
|
---|
| 100 | This.RemoveAll()
|
---|
| 101 | ActiveBasic.Xml.Parser.Parse( reader.ReadToEnd(), This )
|
---|
| 102 | End Sub
|
---|
| 103 |
|
---|
| 104 | /*!
|
---|
| 105 | @brief 指定したストリームからXML文書を読み込む。
|
---|
[452] | 106 | @param stream 読み込み先のストリーム。
|
---|
| 107 | */
|
---|
| 108 | Virtual Sub Load( inStream As System.IO.Stream )
|
---|
[655] | 109 | Load( New System.IO.StreamReader( inStream ) )
|
---|
[452] | 110 | End Sub
|
---|
| 111 |
|
---|
| 112 | /*!
|
---|
| 113 | @brief 指定したファイルからXML文書を読み込む。
|
---|
| 114 | @param ファイルパス。
|
---|
| 115 | */
|
---|
| 116 | Virtual Sub Load( filename As String )
|
---|
[655] | 117 | Dim r = New System.IO.StreamReader( filename )
|
---|
| 118 | Load( r )
|
---|
| 119 | r.Dispose()
|
---|
[452] | 120 | End Sub
|
---|
| 121 |
|
---|
| 122 | /*!
|
---|
[451] | 123 | @brief 指定したストリームにXML文書を保存する。
|
---|
| 124 | @param stream 保存先のストリーム。
|
---|
| 125 | */
|
---|
| 126 | Virtual Sub Save( outStream As System.IO.Stream )
|
---|
[655] | 127 | Dim writer = New IO.StreamWriter( outStream )
|
---|
| 128 | Save( writer )
|
---|
| 129 | writer.Flush()
|
---|
[451] | 130 | End Sub
|
---|
| 131 |
|
---|
| 132 | /*!
|
---|
| 133 | @brief 指定したファイルにXML文書を保存する。
|
---|
| 134 | @param ファイルパス。
|
---|
| 135 | */
|
---|
| 136 | Virtual Sub Save( filename As String )
|
---|
[655] | 137 | Dim w = New IO.StreamWriter( filename )
|
---|
| 138 | Save( w )
|
---|
| 139 | w.Dispose()
|
---|
[451] | 140 | End Sub
|
---|
[468] | 141 |
|
---|
| 142 | /*!
|
---|
| 143 | @brief 指定したテキストライタにXML文書を保存する。
|
---|
| 144 | @param テキストライタ。
|
---|
| 145 | */
|
---|
| 146 | Virtual Sub Save( writer As System.IO.TextWriter )
|
---|
[655] | 147 | writer.Write( InnerXmlSupportedIndent( True ) )
|
---|
[468] | 148 | End Sub
|
---|
[402] | 149 | End Class
|
---|
| 150 |
|
---|
| 151 |
|
---|
| 152 | End Namespace
|
---|
| 153 | End Namespace
|
---|