Ruby 2.2.0 リファレンスマニュアル > ライブラリ一覧 > rexml/documentライブラリ > REXML::Documentクラス

class REXML::Document

クラス・モジュールの継承リスト: REXML::Document < REXML::Element < REXML::Namespace < REXML::XMLTokens < REXML::Parent < Enumerable < REXML::Child < REXML::Node < Object < Kernel < BasicObject

要約

XMLの完全な文書(ドキュメント)を表すクラス。

XML処理命令(Processing Instruction, PI)、 DTD(文書型定義、Document Type Definition)、などを含んでいます。ドキュメントは直下の子ノードをただ一つ持っています(rootと呼び、 REXML::Document#root でアクセスできます)。 2つ目の要素を(REXML::Element#add_elementなどで)追加しようとすると例外(RuntimeError)が発生します。

特異メソッド

定義 説明
entity_expansion_limit -> Integer

実体参照の展開回数の上限を返します。

entity_expansion_limit=(val)

実体参照の展開回数の上限を指定します。

entity_expansion_text_limit -> Integer

実体参照の展開による文字列の増分(テキストのバイト数)の最大値を指定します。

entity_expansion_text_limit=(val)

実体参照の展開による文字列の増分(テキストのバイト数)の最大値を指定します。

new(source = nil, context = {}) -> REXML::Document

Document オブジェクトを生成します。

parse_stream(source, listener) -> ()

XML文書を source から読み込み、パースした結果を listener にコールバックで伝えます。

インスタンスメソッド

定義 説明
add(child) -> ()
self << child -> ()

子ノードを追加します。

clone -> REXML::Document

self を複製します。

doctype -> REXML::DocType | nil

文書の DTD を返します。

encoding -> String

XML 宣言に含まれている XML 文書のエンコーディングを返します。

expanded_name -> String
name -> String

""(空文字列)を返します。

node_type -> Symbol

シンボル :document を返します。

root -> REXML::Element | nil

文書のルート要素を返します。

stand_alone? -> String

XML 宣言の standalone の値を文字列で返します。

version -> String

XML 宣言に含まれている XML 文書のバージョンを返します。

write(output = $stdout, indent = -1, transitive = false, ie_hack = false, encoding=nil) -> ()
write(output: $stdout, indent: -1, transitive: false, ie_hack: false, encoding: nil) -> ()

output に XML 文書を出力します。

xml_decl -> REXML::XMLDecl | nil

文書の XML 宣言を返します。

定数

定義 説明
DECLARATION -> REXML::XMLDecl

この定数は deprecated です。REXML::XMLDecl.default を代わりに使ってください。

継承したメソッド

! != __id__ __send__ instance_eval instance_exec method_missing singleton_method_added singleton_method_removed singleton_method_undefined !~ <=> == === =~ _dump class clone define_singleton_method display enum_for eql? equal? extend freeze frozen? hash initialize initialize_copy inspect instance_of? instance_variable_defined? instance_variable_get instance_variable_set instance_variables is_a? itself marshal_dump marshal_load method methods nil? object_id pretty_inspect pretty_print pretty_print_cycle pretty_print_inspect pretty_print_instance_variables private_methods protected_methods psych_to_yaml public_method public_methods public_send remove_instance_variable respond_to? respond_to_missing? send singleton_class singleton_method singleton_methods taint tainted? tap to_ary to_hash to_int to_io to_proc to_regexp to_s to_str trust untaint untrust untrusted? .yaml_tag ::ARGF ::ARGV ::DATA ::ENV ::FALSE ::NIL ::RUBY_COPYRIGHT ::RUBY_DESCRIPTION ::RUBY_ENGINE ::RUBY_PATCHLEVEL ::RUBY_PLATFORM ::RUBY_RELEASE_DATE ::RUBY_REVISION ::RUBY_VERSION ::SCRIPT_LINES__ ::STDERR ::STDIN ::STDOUT ::TOPLEVEL_BINDING ::TRUE bytes next_sibling next_sibling= parent parent= previous_sibling previous_sibling= remove replace_with add_attribute add_attributes add_element add_namespace attribute attributes cdatas comments context context= delete_attribute delete_element delete_namespace document each_element each_element_with_attribute each_element_with_text elements get_elements get_text has_attributes? has_elements? has_text? instructions namespace namespaces next_element prefixes previous_element raw root_node text text= texts whitespace xpath ::UNDEFINED << [] []= children deep_clone delete delete_at delete_if each each_index index insert_after insert_before length parent? replace_child unshift