クラス
-
REXML
:: AttlistDecl (6) -
REXML
:: Attribute (14) -
REXML
:: Attributes (15) -
REXML
:: CData (3) -
REXML
:: Child (8) -
REXML
:: Comment (7) -
REXML
:: Declaration (2) -
REXML
:: DocType (16) -
REXML
:: Document (14) -
REXML
:: Element (42) -
REXML
:: Elements (13) -
REXML
:: Entity (10) -
REXML
:: ExternalEntity (2) -
REXML
:: Formatters :: Default (1) -
REXML
:: Formatters :: Pretty (4) -
REXML
:: Instruction (7) -
REXML
:: NotationDecl (7) -
REXML
:: Parent (28) -
REXML
:: ParseException (4) -
REXML
:: Parsers :: PullEvent (15) -
REXML
:: Parsers :: PullParser (6) -
REXML
:: Parsers :: SAX2Parser (6) -
REXML
:: Parsers :: StreamParser (1) -
REXML
:: Parsers :: UltraLightParser (2) -
REXML
:: Text (10) -
REXML
:: XMLDecl (12)
モジュール
-
REXML
:: Namespace (6) -
REXML
:: Node (5) -
REXML
:: SAX2Listener (17) -
REXML
:: StreamListener (14)
キーワード
- << (4)
- <=> (2)
- == (4)
- [] (6)
- []= (5)
- add (5)
-
add
_ attribute (2) -
add
_ attributes (1) -
add
_ element (1) -
add
_ namespace (2) - attlistdecl (2)
- attlistdecl? (1)
- attribute (1)
-
attribute
_ of (1) - attributes (1)
-
attributes
_ of (1) - bytes (1)
- cdata (2)
- cdata? (1)
- cdatas (1)
- characters (1)
- children (1)
- clone (8)
- collect (1)
- comment (2)
- comment? (1)
- comments (1)
- compact (1)
- compact= (1)
- content (1)
- content= (1)
- context (3)
- context= (1)
- deafen (1)
-
deep
_ clone (1) - delete (3)
-
delete
_ all (2) -
delete
_ at (1) -
delete
_ attribute (1) -
delete
_ element (1) -
delete
_ if (2) -
delete
_ namespace (1) - doctype (4)
- doctype? (1)
-
doctype
_ end (1) - document (2)
- dowrite (1)
- each (6)
-
each
_ attribute (1) -
each
_ child (2) -
each
_ element (1) -
each
_ element _ with _ attribute (1) -
each
_ element _ with _ text (1) -
each
_ index (2) - element (1)
- element= (1)
-
element
_ name (1) - elementdecl (2)
- elementdecl? (1)
- elements (1)
- empty? (3)
- encoding (2)
-
end
_ document (1) -
end
_ element (1) -
end
_ element? (1) -
end
_ prefix _ mapping (1) - entities (1)
- entity (2)
- entitydecl (2)
- entitydecl? (1)
-
event
_ type (1) - external (1)
-
external
_ id (1) -
find
_ first _ recursive (1) -
get
_ attribute (1) -
get
_ attribute _ ns (1) -
get
_ elements (1) -
get
_ text (1) -
has
_ attributes? (1) -
has
_ elements? (1) -
has
_ name? (1) -
has
_ next? (1) -
has
_ text? (1) - include? (1)
- index (2)
-
index
_ in _ parent (1) - inject (1)
-
insert
_ after (1) -
insert
_ before (1) - instruction (1)
- instruction? (1)
- instructions (1)
- length (2)
- line (1)
- listen (5)
-
local
_ name (1) - name (5)
- namespace (2)
- namespaces (3)
- ndata (1)
-
next
_ element (1) -
next
_ sibling (1) -
next
_ sibling= (1) -
next
_ sibling _ node (1) -
node
_ type (9) - normalized (1)
- normalized= (1)
- notation (1)
- notationdecl (2)
- notationdecl? (1)
- notations (1)
- nowrite (1)
- parent (1)
- parent= (1)
- parent? (2)
- parse (2)
- peek (1)
- position (1)
- prefix (2)
- prefixes (2)
-
previous
_ element (1) -
previous
_ sibling= (1) -
processing
_ instruction (1) - progress (1)
- pubid (1)
- public (2)
- public= (1)
- pull (1)
- push (1)
- raw (2)
- raw= (1)
- ref (1)
- remove (1)
-
replace
_ child (1) -
replace
_ with (1) - rewind (1)
- root (2)
-
root
_ node (1) - size (3)
-
stand
_ alone? (2) - standalone (1)
- standalone= (1)
-
start
_ document (1) -
start
_ element (1) -
start
_ element? (1) -
start
_ prefix _ mapping (1) - string (1)
- string= (1)
- system (2)
- system= (1)
-
tag
_ end (1) -
tag
_ start (1) - target (1)
- target= (1)
- text (2)
- text= (1)
- text? (1)
- texts (1)
-
to
_ a (3) -
to
_ s (10) -
to
_ string (1) - unnormalized (1)
- unshift (2)
- value (4)
- value= (1)
- version (2)
- whitespace (1)
- width (1)
- width= (1)
- write (11)
- writeencoding (1)
- writethis (1)
-
xml
_ decl (1) - xmldecl (3)
- xmldecl? (1)
- xpath (2)
検索結果
先頭5件
-
REXML
:: DocType # entities -> { String => REXML :: Entity } (27907.0) -
DTD で宣言されている実体の集合を Hash で返します。
...体参照名をキーとし、対応する REXML::Entity オブジェクト
を値とするハッシュテーブルです。
これには、XML のデフォルトの実体(gt, lt, quot, apos)も含まれています。
//emlist[][ruby]{
doctype = REXML::Document.new(<<EOS).doctype
<!DOCTYPE foo [......<!ENTITY bar "barbarbarbar">
]>
EOS
p doctype.entities # => { "gt" => #<REXML::Entity: ...>,
# "lt" => #<REXML::Entity: ...>, ... }
p doctype.entities["bar"].to_s # => "<!ENTITY bar \"barbarbarbar\">"
p doctype.entities["gt"].to_s # => "<!ENTITY gt \">\">"
//}... -
REXML
:: Element # delete _ attribute(key) -> REXML :: Attribute | nil (27907.0) -
要素から key という属性名の属性を削除します。
...合は削除されずに、nil を返します。
@param key 削除する要素(文字列(属性名) or REXML::Attributeオブジェクト)
//emlist[][ruby]{
require 'rexml/document'
e = REXML::Element.new("E")
e.add_attribute("x", "foo"); e # => <E x='foo'/>
e.add_attribute("y:x", "bar"); e # =>... -
REXML
:: Attributes # each _ attribute {|attribute| . . . } -> () (27607.0) -
各属性に対しブロックを呼び出します。
...各属性に対しブロックを呼び出します。
個々の属性は REXML::Attribute オブジェクトで渡されます。
//emlist[][ruby]{
require 'rexml/document'
doc = REXML::Document.new(<<EOS)
<root xmlns:foo="http://example.org/foo"
xmlns:bar="http://example.org/bar">
<a fo... -
REXML
:: SAX2Listener # characters(text) -> () (27607.0) -
XML の文字データに出会ったときに呼び出されるコールバックメソッドです。
XML の文字データに出会ったときに呼び出されるコールバックメソッドです。
@param text 文字データ(文字列)が渡されます -
REXML
:: StreamListener # instruction(name , instruction) -> () (27607.0) -
XML処理命令(PI)をパースしたときに呼び出されるコールバックメソッドです。
XML処理命令(PI)をパースしたときに呼び出されるコールバックメソッドです。
@param name ターゲット名が文字列で渡されます
@param instruction 処理命令の内容が文字列で渡されます
=== 例
<?xml-stylesheet type="text/css" href="style.css"?>
というPIに対し
name: "xml-stylesheet"
instruction: " type=\"text/css\" href=\"style.css\""
という引数が渡されます。 -
REXML
:: StreamListener # tag _ start(name , attrs) -> () (27607.0) -
開始タグをパースしたとき に呼び出されるコールバックメソッドです。
開始タグをパースしたとき
に呼び出されるコールバックメソッドです。
@param name タグ名が文字列で渡されます
@param attrs タグの属性が"属性名" => "属性値"という Hash で渡されます
=== 例
<tag attr1="value1" attr2="value2">
という開始タグに対し、
name: "tag"
attrs: {"attr1" => "value1", "attr2" => "value2"}
という引数が渡されます。 -
REXML
:: ParseException # position -> Integer (27310.0) -
パースエラーが起きた(XML上の)場所を先頭からのバイト数で返します。
パースエラーが起きた(XML上の)場所を先頭からのバイト数で返します。 -
REXML
:: Attributes # get _ attribute(name) -> Attribute | nil (27307.0) -
name という名前の属性を取得します。
...という名前を持つ属性がない場合は nil を返します。
@param name 属性名(文字列)
@see REXML::Attributes#[]
//emlist[][ruby]{
require 'rexml/document'
doc = REXML::Document.new(<<-EOS)
<root xmlns:foo="http://example.org/foo"
xmlns:bar="http://example.org/bar">
<a... -
REXML
:: Attributes # get _ attribute _ ns(namespace , name) -> REXML :: Attribute | nil (27307.0) -
namespace と name で特定される属性を返します。
...ることができます。
@param namespace 名前空間(URI, 文字列)
@param name 属性名(文字列)
//emlist[][ruby]{
require 'rexml/document'
doc = REXML::Document.new(<<-EOS)
<root xmlns:foo="http://example.org/foo"
xmlns:bar="http://example.org/bar">
<a foo:att='1' bar:att='2' a... -
REXML
:: DocType # entity(name) -> String | nil (27307.0) -
name という実体参照名を持つ実体を文字列で返します。
...れる文字列は非正規化(REXML::Entity#unnormalized 参照)
された文字列が返されます。
name という名前を持つ実体が存在しない場合には nil を返します。
@param name 実体参照名(文字列)
//emlist[][ruby]{
doctype = REXML::Document.new(<<EOS).doctype... -
REXML
:: DocType # node _ type -> Symbol (27307.0) -
Symbol :doctype を返します。
Symbol :doctype を返します。 -
REXML
:: ExternalEntity # write(output , indent) -> () (27307.0) -
output へ self を文字列化して出力します。
...output へ self を文字列化して出力します。
このメソッドは deprecated です。REXML::Formatter で
出力してください。
@param output 出力先の IO オブジェクト
@param indent インデントの大きさ。無視されます。... -
REXML
:: Formatters :: Pretty # compact -> bool (27307.0) -
出力をコンパクトにするかどうかを返します。
...出力をコンパクトにするかどうかを返します。
これが真の場合、出力の空白をできる限り削除しようとします。
デフォルト値は false です。
@see REXML::Formatters::Pretty#compact=... -
REXML
:: Formatters :: Pretty # compact=(c) (27307.0) -
出力をコンパクトにするかどうかを設定します。
...出力をコンパクトにするかどうかを設定します。
@param c コンパクトな出力をするかどうかを指定します。
@see REXML::Formatters::Pretty#compact... -
REXML
:: Formatters :: Pretty # width -> Integer (27307.0) -
出力のページ幅を返します。
...出力のページ幅を返します。
デフォルトは80です。
@see REXML::Formatters::Pretty#width=... -
REXML
:: Formatters :: Pretty # width=(w) (27307.0) -
出力のページ幅を設定します。
...出力のページ幅を設定します。
@param w ページ幅の設定値
@see REXML::Formatters::Pretty#width... -
REXML
:: ParseException # context -> [Integer , Integer , Integer] (19210.0) -
パースエラーが起きた(XML上の)場所を返します。
...の)場所を返します。
要素3個の配列で、
[position, lineno, line]
という形で返します。
position, line は
REXML::ParseException#position
REXML::ParseException#line
と同じ値です。
lineno は IO#lineno が返す意味での行数です。
通常は line と同じ値... -
REXML
:: Attribute # element -> REXML :: Element (18607.0) -
その属性が属する要素を返します。
その属性が属する要素を返します。 -
REXML
:: Attributes # delete(attribute) -> REXML :: Element (18607.0) -
指定した属性を取り除きます。
...列もしくは REXML::Attribute オブジェクトを指定します
self が属する要素(REXML::Element)を返します。
@param attribute 取り除く属性(文字列もしくは REXML::Attribute オブジェクト)
//emlist[][ruby]{
require 'rexml/document'
doc = REXML::Document.new(<<-E... -
REXML
:: Attributes # delete _ all(name) -> [REXML :: Attribute] (18607.0) -
name という名前を持つ属性をすべて削除します。
...除します。
削除された属性を配列で返します。
@param name 削除する属性の名前
//emlist[][ruby]{
require 'rexml/document'
doc = REXML::Document.new(<<-EOS)
<root xmlns:foo="http://example.org/foo"
xmlns:bar="http://example.org/bar">
<a foo:att='1' bar:att='2' at... -
REXML
:: Child # document -> REXML :: Document | nil (18607.0) -
そのノードが属する document (REXML::Document) を返します。
...そのノードが属する document (REXML::Document) を返します。
属する document が存在しない場合は nil を返します。... -
REXML
:: Comment # string -> String (18607.0) -
コメント文字列を返します。
コメント文字列を返します。 -
REXML
:: DocType # attribute _ of(element , attribute) -> String | nil (18607.0) -
DTD 内の属性リスト宣言で、 element という名前の要素の attribute という 名前の属性のデフォルト値を返します。
...合は nil を返します。
@param element 要素名(文字列)
@param attribute 属性名(文字列)
//emlist[][ruby]{
require 'rexml/document'
doctype = REXML::Document.new(<<EOS).doctype
<!DOCTYPE books [
<!ELEMENT book (comment)>
<!ELEMENT comment (#PCDATA)>
<!ATTLIST book
author... -
REXML
:: DocType # attributes _ of(element) -> [REXML :: Attribute] (18607.0) -
DTD 内の属性リスト宣言で、 element という名前の要素に対し宣言されている 属性の名前とデフォルト値を REXML::Attribute の配列で返します。
...デフォルト値を REXML::Attribute の配列で返します。
名前とデフォルト値のペアは、各 Attribute オブジェクトの
REXML::Attribute#name と
REXML::Attribute#value で表現されます。
//emlist[][ruby]{
require 'rexml/document'
doctype = REXML::Document.new(<<EOS... -
REXML
:: DocType # notation(name) -> REXML :: NotationDecl | nil (18607.0) -
DTD に含まれている記法宣言 (REXML::NotationDecl) で name という名前を持つものを返します。
...DTD に含まれている記法宣言 (REXML::NotationDecl) で
name という名前を持つものを返します。
name という名前を持つ記法宣言が存在しない場合は nil を返します。
@param name 検索する記法名... -
REXML
:: DocType # notations -> [REXML :: NotationDecl] (18607.0) -
DTD に含まれている記法宣言 (REXML::NotationDecl) を 配列で返します。
...DTD に含まれている記法宣言 (REXML::NotationDecl) を
配列で返します。... -
REXML
:: Document # doctype -> REXML :: DocType | nil (18607.0) -
文書の DTD を返します。
文書の DTD を返します。
文書が DTD を持たない場合は nil を返します。 -
REXML
:: Document # root -> REXML :: Element | nil (18607.0) -
文書のルート要素を返します。
文書のルート要素を返します。
文書がルート要素を持たない場合は nil を返します。 -
REXML
:: Element # add _ attribute(attr) -> () (18607.0) -
要素の属性を追加します。 同じ名前の属性がすでにある場合はその属性を新しい 属性で置き換えます。
...で渡す方法と REXML::Attribute オブジェクトを
渡す方法です。
文字列2つで指定する場合、属性値は unnormalized な文字列を渡す必要があります。
@param key 属性名(文字列)
@param value 属性値(文字列)
@param attr 属性(REXML::Attribute オブ......ジェクト)
//emlist[][ruby]{
require 'rexml/document'
doc = REXML::Document.new("<e/>")
doc.root.add_attribute("a", "b"); doc.root # => <e a='b'/>
doc.root.add_attribute("x:a", "c"); doc.root # => <e a='b' x:a='c'/>
doc.root.add_attribute(REXML::Attribute.new("b", "d"))
doc.root # => <e a='b' x:... -
REXML
:: Element # add _ attributes(attrs) -> () (18607.0) -
要素の属性を複数追加します。 同じ名前の属性がすでにある場合はその属性を新しい 属性で置き換えます。
...属性の属性名と属性値の対の集合(Array or Hash)
//emlist[][ruby]{
require 'rexml/document'
e = REXML::Element.new("e")
e.add_attributes({"a" => "b", "c" => "d"})
e # => <e a='b' c='d'/>
e = REXML::Element.new("e")
e.add_attributes([["a", "b"], ["c", "d"]])
e # => <e a='b' c='d'/>
//}... -
REXML
:: Element # attribute(name , namespace = nil) -> REXML :: Attribute | nil (18607.0) -
name で指定される属性を返します。
...name で指定される属性を返します。
属性は REXML::Attribute オブジェクトの形で返します。
name は "foo:bar" のように prefix を指定することができます。
namespace で名前空間の URI を指定することで、その名前空間内で
name という......は nil を返します。
@param name 属性名(文字列)
@param namespace 名前空間のURI(文字列)
//emlist[][ruby]{
require 'rexml/document'
doc = REXML::Document.new(<<-EOS)
<root xmlns:foo="http://example.org/foo"
xmlns:bar="http://example.org/bar">
<a foo:att='1' bar:att='2' at... -
REXML
:: Element # attributes -> REXML :: Attributes (18607.0) -
要素が保持している属性の集合を返します。
要素が保持している属性の集合を返します。 -
REXML
:: Element # cdatas -> [REXML :: CData] (18607.0) -
すべての cdata 子ノードの配列を返します。
すべての cdata 子ノードの配列を返します。
返される配列は freeze されます。 -
REXML
:: Element # comments -> [REXML :: Comments] (18607.0) -
すべての comment 子ノードの配列を返します。
すべての comment 子ノードの配列を返します。
返される配列は freeze されます。 -
REXML
:: Element # document -> REXML :: Document | nil (18607.0) -
self が属する文書(REXML::Document)オブジェクトを返します。
...self が属する文書(REXML::Document)オブジェクトを返します。
属する文書がない場合には nil を返します。... -
REXML
:: Element # elements -> REXML :: Elements (18607.0) -
要素が保持している子要素の集合を返します。
要素が保持している子要素の集合を返します。 -
REXML
:: Element # instructions -> [REXML :: Instraction] (18607.0) -
すべての instruction 子ノードの配列を返します。
すべての instruction 子ノードの配列を返します。
返される配列は freeze されます。 -
REXML
:: Element # previous _ element -> Element | nil (18607.0) -
前の兄弟要素を返します。
前の兄弟要素を返します。
前の要素が存在しない場合は nil を返します。 -
REXML
:: Element # root -> REXML :: Element (18607.0) -
self が属する文書のルート要素を返します。
...self が属する文書のルート要素を返します。
//emlist[][ruby]{
require 'rexml/document'
doc = REXML::Document.new(<<EOS)
<root>
<children>
<grandchildren />
</children>
</root>
EOS
children = doc.get_elements("/root/children").first
children.name # => "children"
children.root.name... -
REXML
:: Element # text=(text) (18607.0) -
「先頭の」テキストノードを text で置き換えます。
...ノードが追加されます。
text には文字列、REXML::Text、nil のいずれかが指定できます。
REXML::Text オブジェクトを指定した場合には、それが設定され、
文字列を指定した場合には
REXML::Text.new(text, whitespace(), nil, raw())
で生成さ......初のテキストノードが削除されます。
@param text 置き換え後のテキスト(文字列、REXML::Text, nil(削除))
//emlist[][ruby]{
require 'rexml/document'
doc = REXML::Document.new('<a><b/></a>')
doc.to_s # => "<a><b/></a>"
doc.root.text = "Foo"; doc.to_s # => "<a><b/>Foo</a>"... -
REXML
:: Element # texts -> [REXML :: Texts] (18607.0) -
すべてのテキスト子ノードの配列を返します。
すべてのテキスト子ノードの配列を返します。
返される配列は freeze されます。 -
REXML
:: Parsers :: SAX2Parser # listen(ary , listener) -> () (18607.0) -
コールバックをパーサに登録します。
...わります。
ブロックを指定した場合はそのブロックがコールバックされます。
ブロックを指定しない場合は REXML::SAX2Listener を include した
クラスのオブジェクトを指定します。
sym は以下のシンボルが指定でき、どの場合......か
については、
REXML::SAX2Listener の対応するメソッドで詳しく説明されていますので
そちらを参照してください。
* :start_document
(XML文書開始, REXML::SAX2Listener#start_document)
* :end_document
(XML文書終了, REXML::SAX2Listener#end_docu......素開始, REXML::SAX2Listener#start_element)
* :end_element
(要素終了, REXML::SAX2Listener#end_element)
* :start_prefix_mapping
(名前空間接頭辞導入, REXML::SAX2Listener#start_prefix_mapping)
* :end_prefix_mapping
(名前空間接頭辞適用終了, REXML::SAX2Listener... -
REXML
:: Parsers :: SAX2Parser # listen(listener) -> () (18607.0) -
コールバックをパーサに登録します。
...わります。
ブロックを指定した場合はそのブロックがコールバックされます。
ブロックを指定しない場合は REXML::SAX2Listener を include した
クラスのオブジェクトを指定します。
sym は以下のシンボルが指定でき、どの場合......か
については、
REXML::SAX2Listener の対応するメソッドで詳しく説明されていますので
そちらを参照してください。
* :start_document
(XML文書開始, REXML::SAX2Listener#start_document)
* :end_document
(XML文書終了, REXML::SAX2Listener#end_docu......素開始, REXML::SAX2Listener#start_element)
* :end_element
(要素終了, REXML::SAX2Listener#end_element)
* :start_prefix_mapping
(名前空間接頭辞導入, REXML::SAX2Listener#start_prefix_mapping)
* :end_prefix_mapping
(名前空間接頭辞適用終了, REXML::SAX2Listener... -
REXML
:: StreamListener # attlistdecl(element _ name , attributes , raw _ content) -> () (18607.0) -
DTDの属性リスト宣言をパースしたときに呼び出されるコールバックです。
DTDの属性リスト宣言をパースしたときに呼び出されるコールバックです。
@param element_name 要素名が文字列で渡されます
@param attributes 属性名とそのデフォルト値の対応が
{ 属性名文字列 => デフォルト値文字列(無ければnil) } という
ハッシュテーブルで渡されます
@param raw_content 文書内の属性リスト宣言の文字列がそのまま渡されます
=== 例
<!ATTLIST a att CDATA #REQUIRED xyz CDATA "foobar">
という属性リスト宣言に対しては
element_... -
REXML
:: StreamListener # text(text) -> () (18607.0) -
XML文書内のテキストをパースしたときに呼び出されるコールバックメソッドです。
XML文書内のテキストをパースしたときに呼び出されるコールバックメソッドです。
@param text テキストが文字列で渡されます -
REXML
:: Text # doctype -> REXML :: DocType | nil (18607.0) -
テキストノードが属する文書の DTD を返します。
...テキストノードが属する文書の DTD を返します。
そのような文書(REXML::Document)が存在しない、すなわち
テキストノードの親ノードを辿っても REXML::Document に到達しない、
場合には nil を返します。
@see REXML::DocType... -
REXML
:: Text # to _ s -> String (18361.0) -
テキストの内容を正規化(すべての実体をエスケープ)された状態で返します。
...まり返り値は XML のテキストとして妥当です。
結果は REXML::Text.new で指定した entity_filter を反映しています。
@see REXML::Text#value
//emlist[][ruby]{
require 'rexml/document'
t = REXML::Text.new("< & foobar", false, nil, false)
t.to_s # => "< & foobar"... -
REXML
:: ParseException # to _ s -> String (18310.0) -
例外情報を文字列化して返します。
例外情報を文字列化して返します。 -
REXML
:: AttlistDecl # element _ name -> String (18307.0) -
属性を定義しているエレメントの名前を返します。
属性を定義しているエレメントの名前を返します。 -
REXML
:: AttlistDecl # node _ type -> Symbol (18307.0) -
Symbol :attlistdecl を返します。
Symbol :attlistdecl を返します。 -
REXML
:: AttlistDecl # write(out , indent = -1) -> () (18307.0) -
self を out に出力します。
self を out に出力します。
@param out 出力先の IO オブジェクト
@param indent インデント数(無視されます) -
REXML
:: Attribute # element=(element) (18307.0) -
self が属する要素を変更します。
...self が属する要素を変更します。
@param element 変更先の要素(REXML::Element)... -
REXML
:: Attribute # node _ type -> Symbol (18307.0) -
「:attribute」というシンボルを返します。
「:attribute」というシンボルを返します。 -
REXML
:: Attribute # to _ s -> String (18307.0) -
正規化された属性値を返します。
正規化された属性値を返します。
属性値の正規化については XML の仕様を参考にしてください。 -
REXML
:: Attribute # to _ string -> String (18307.0) -
"name='value'" という形式の文字列を返します。
..."name='value'" という形式の文字列を返します。
//emlist[][ruby]{
require 'rexml/document'
e = REXML::Element.new("el")
e.add_attribute("ns:r", "rval")
p e.attributes.get_attribute("r").to_string # => "ns:r='rval'"
//}... -
REXML
:: Attribute # write(output , indent = -1) -> object (18307.0) -
output に self の情報を name='value' という形式で書き込みます。
output に self の情報を name='value' という形式で書き込みます。
output が返ります。
@param output 書き込み先の IO オブジェクト
@param indent インデントレベル、ここでは無視される -
REXML
:: Attribute # xpath -> String (18307.0) -
その属性を指定する xpath 文字列を返します。
その属性を指定する xpath 文字列を返します。
例えば "/foo/bar/@ns:r" という文字列を返します。 -
REXML
:: Attributes # length -> Integer (18307.0) -
属性の個数を返します。
...属性の個数を返します。
//emlist[][ruby]{
require 'rexml/document'
doc = REXML::Document.new(<<EOS)
<root xmlns:foo="http://example.org/foo"
xmlns:bar="http://example.org/bar">
<a foo:att='1' bar:att='2' att='<'/>
</root>
EOS
a = doc.get_elements("/root/a").first
p a.attribu... -
REXML
:: Attributes # to _ a -> [Attribute] (18307.0) -
属性の配列を返します。
...属性の配列を返します。
//emlist[][ruby]{
require 'rexml/document'
doc = REXML::Document.new("<a x='1' y='2' z='3' />")
doc.root.attributes.to_a # => [x='1', y='2', z='3']
//}... -
REXML
:: CData # to _ s -> String (18307.0) -
テキスト文字列を返します。
...テキスト文字列を返します。
@see REXML::Text#value, REXML::Text#to_s
//emlist[][ruby]{
require 'rexml/document'
doc = REXML::Document.new(<<EOS)
<root><![CDATA[foobar baz]]></root>
EOS
doc.root[0].class # => REXML::CData
doc.root[0].value # => "foobar baz"
//}... -
REXML
:: Child # bytes (18307.0) -
@todo
@todo -
REXML
:: Child # next _ sibling -> REXML :: Node (18307.0) -
次の隣接ノードを返します。
...次の隣接ノードを返します。
REXML::Node#next_sibling_node の別名です。
@see REXML::Child#next_sibling=... -
REXML
:: Child # next _ sibling=(other) (18307.0) -
other を self の次の隣接ノードとします。
...ther を挿入します。
@param other 挿入するノード
//emlist[][ruby]{
require 'rexml/document'
a = REXML::Element.new("a")
b = a.add_element("b")
c = REXML::Element.new("c")
b.next_sibling = c
d = REXML::Element.new("d")
b.previous_sibling = d
p a.to_s # => "<a><d/><b/><c/></a>"
//}... -
REXML
:: Child # parent -> REXML :: Parent|nil (18307.0) -
親ノードを返します。
...親ノードを返します。
ルートノードの場合は nil を返します。
@see REXML::Child#parent=... -
REXML
:: Child # parent=(other) (18307.0) -
other を親ノードに設定します。
...メソッドだけでは other の子ノード集合に self は追加されません。
つまりこのメソッドを呼び出した直後は不完全な状態であり、親ノード側を
適切に設定する必要があります。
@param other 新たな親ノード
@see REXML::Child#parent... -
REXML
:: Child # replace _ with(child) -> self (18307.0) -
親ノードの子ノード列上において、 self を child に置き換えます。
...親ノードの子ノード列上において、 self を child に置き換えます。
@param child 置き換え後のノード
@see REXML::Parent#replace_child... -
REXML
:: Comment # node _ type -> Symbol (18307.0) -
シンボル :comment を返します。
シンボル :comment を返します。 -
REXML
:: Comment # string=(value) (18307.0) -
コメント文字列を設定します。
コメント文字列を設定します。
@param value 設定する文字列 -
REXML
:: Comment # to _ s -> String (18307.0) -
コメント文字列を返します。
コメント文字列を返します。 -
REXML
:: Declaration # to _ s -> String (18307.0) -
ノードを文字列化します。
ノードを文字列化します。 -
REXML
:: Declaration # write(output , indent) -> () (18307.0) -
output にノードを出力します。
...output にノードを出力します。
このメソッドは deprecated です。REXML::Formatter で
出力してください。
@param output 出力先の IO オブジェクト
@param indent インデントの大きさ。無視されます。... -
REXML
:: DocType # context -> { Symbol => object } (18307.0) -
DTD が属する文書の「コンテキスト」を返します。
...DTD が属する文書の「コンテキスト」を返します。
具体的には親ノードである REXML::Document オブジェクトの
REXML::Element#context を返します。
コンテキストの具体的な内容については REXML::Element#context を
参照してください。... -
REXML
:: DocType # external _ id -> String | nil (18307.0) -
DTD が外部サブセットを用いている場合は "SYSTEM", "PUBLIC" の いずれかの文字列を返します。
...t[][ruby]{
require 'rexml/document'
doctype = REXML::Document.new(<<EOS).doctype
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
EOS
doctype.name # => "html"
doctype.external_id # => "PUBLIC"
doctype = REXML::Document.new(<<EO... -
REXML
:: DocType # system -> String | nil (18307.0) -
DTD のシステム識別子を返します。
...子を返します。
DTD が外部サブセットを含んでいない場合は nil を返します。
//emlist[][ruby]{
require 'rexml/document'
doctype = REXML::Document.new(<<EOS).doctype
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1......-strict.dtd">
EOS
doctype.system # => "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
doctype.public # => "-//W3C//DTD XHTML 1.0 Strict//EN"
doctype = REXML::Document.new(<<EOS).doctype
<!DOCTYPE root SYSTEM "foobar">
EOS
doctype.system # => "foobar"
doctype.public # => nil
//}... -
REXML
:: DocType # write(output , indent = 0 , transitive = false , ie _ hack = false) -> () (18307.0) -
output に DTD を出力します。
...output に DTD を出力します。
このメソッドは deprecated です。REXML::Formatter で
出力してください。
@param output 出力先の IO オブジェクト
@param indent インデントの深さ。指定しないでください。
@param transitive 無視されます。指定......しないでください。
@param ie_hack 無視されます。指定しないでください。
//emlist[][ruby]{
require 'rexml/document'
doctype = REXML::Document.new(<<EOS).doctype
<!DOCTYPE books [
<!ELEMENT book (comment)>
<!ELEMENT comment (#PCDATA)>
<!ATTLIST book
author CDATA #... -
REXML
:: Document # node _ type -> Symbol (18307.0) -
シンボル :document を返します。
シンボル :document を返します。 -
REXML
:: Document # stand _ alone? -> String (18307.0) -
XML 宣言の standalone の値を文字列で返します。
...XML 宣言の standalone の値を文字列で返します。
//emlist[][ruby]{
require 'rexml/document'
doc = REXML::Document.new(<<EOS)
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<e />
EOS
doc.stand_alone? # => "yes"
//}... -
REXML
:: Document # write(output = $ stdout , indent = -1 , transitive = false , ie _ hack = false , encoding=nil) -> () (18307.0) -
output に XML 文書を出力します。
...を含んでいなくとも
出力される XML はデフォルトの XML 宣言を含んでいるべきであるが、
REXML は明示しない限り(つまりXML宣言を REXML::Document#add で
追加しない限り)
それをしない、ということである。XML-RPCのような利用法で... -
REXML
:: Document # write(output: $ stdout , indent: -1 , transitive: false , ie _ hack: false , encoding: nil) -> () (18307.0) -
output に XML 文書を出力します。
...を含んでいなくとも
出力される XML はデフォルトの XML 宣言を含んでいるべきであるが、
REXML は明示しない限り(つまりXML宣言を REXML::Document#add で
追加しない限り)
それをしない、ということである。XML-RPCのような利用法で... -
REXML
:: Element # add _ attribute(key , value) -> () (18307.0) -
要素の属性を追加します。 同じ名前の属性がすでにある場合はその属性を新しい 属性で置き換えます。
...で渡す方法と REXML::Attribute オブジェクトを
渡す方法です。
文字列2つで指定する場合、属性値は unnormalized な文字列を渡す必要があります。
@param key 属性名(文字列)
@param value 属性値(文字列)
@param attr 属性(REXML::Attribute オブ......ジェクト)
//emlist[][ruby]{
require 'rexml/document'
doc = REXML::Document.new("<e/>")
doc.root.add_attribute("a", "b"); doc.root # => <e a='b'/>
doc.root.add_attribute("x:a", "c"); doc.root # => <e a='b' x:a='c'/>
doc.root.add_attribute(REXML::Attribute.new("b", "d"))
doc.root # => <e a='b' x:... -
REXML
:: Element # add _ element(element , attrs = nil) -> Element (18307.0) -
子要素を追加します。
...子要素を追加します。
element として追加する要素を指定します。
REXML::Element オブジェクトもしくは文字列を指定します。
element として REXML::Element オブジェクトを指定した場合、それが追加されます。
文字列を指定した場......た要素です。
@param element 追加する要素
@param attrs 追加する要素に設定する属性
//emlist[][ruby]{
require 'rexml/document'
doc = REXML::Document.new('<a/>')
el = doc.root.add_element 'my-tag' # => <my-tag/>
doc.root.to_s # => "<a><my-tag/></a>"
el = doc.root.add_element '......'val1' attr2='val2'/>
doc.root.to_s # => "<a><my-tag/><my-tag attr1='val1' attr2='val2'/></a>"
el = REXML::Element.new 'my-tag'
doc.root.add_element el # => <my-tag/>
doc.root.to_s # => "<a><my-tag/><my-tag attr1='val1' attr2='val2'/><my-tag/></a>"
//}
@see REXML::Elements#add, REXML::Element.new... -
REXML
:: Element # context -> {Symbol => object} | nil (18307.0) -
要素の「コンテキスト」を Hash で返します。
...要素の「コンテキスト」を Hash で返します。
コンテキストとは text node (REXML::Text) での特別な文字、特に空白について
の取り扱いについての設定です。
以下の Symbol をハッシュのキーとして使います。
: :respect_whitespace......。
また、すべての要素で空白を考慮して欲しい場合には
:all を指定します。
デフォルト値は :all です。
REXML::Element#whitespace も参照してください。
: :compress_whitespace
空白を無視して欲しい要素の名前の集合を文字列の......ect_whitespace での指定を上書きします。
すべての要素で空白を無視して欲しい場合には
:all を指定します。
REXML::Element#whitespace も参照してください。
: :ignore_whitespace_nodes
空白のみからなるノードを無視して欲しい要素... -
REXML
:: Element # context=(value) (18307.0) -
要素の「コンテキスト」を Hash で設定します。
...要素の「コンテキスト」を Hash で設定します。
コンテキストとは、 text node (REXML::Text) での特別な文字、特に空白について
の取り扱いについての設定です。
以下の Symbol をハッシュのキーとして使います。
: :respect_whitespac......。
また、すべての要素で空白を考慮して欲しい場合には
:all を指定します。
デフォルト値は :all です。
REXML::Element#whitespace も参照してください。
: :compress_whitespace
空白を無視して欲しい要素の名前の集合を文字列の......ect_whitespace での指定を上書きします。
すべての要素で空白を無視して欲しい場合には
:all を指定します。
REXML::Element#whitespace も参照してください。
: :ignore_whitespace_nodes
空白のみからなるノードを無視して欲しい要素... -
REXML
:: Element # delete _ element(element) -> REXML :: Element (18307.0) -
子要素を削除します。
...子要素を削除します。
element で削除する要素を指定できます。整数、文字列、REXML::Element
オブジェクトのいずれかが指定できます。
REXML::Element を指定すると、その要素が削除されます。
整数を指定すると、element 番目の......素がマッチする場合はそのうち1つが削除されます。
@param element 削除する要素
@see REXML::Elements#delete
//emlist[][ruby]{
require 'rexml/document'
doc = REXML::Document.new '<a><b/><c/><c id="1"/><d/><c/></a>'
doc.delete_element("/a/b")
doc.to_s # => "<a><c/><c id='1'/... -
REXML
:: Element # delete _ namespace(namespace = "xmlns") -> self (18307.0) -
名前空間を要素から削除します。
...はデフォルトの名前空間を削除します。
@param namespace 削除する名前空間の prefix
//emlist[][ruby]{
require 'rexml/document'
doc = REXML::Document.new "<a xmlns:foo='bar' xmlns='twiddle'/>"
doc.root.delete_namespace
doc.to_s # => "<a xmlns:foo='bar'/>"
doc.root.delete_name... -
REXML
:: Element # each _ element(xpath = nil) {|element| . . . } -> () (18307.0) -
各子要素を引数としてブロックを呼び出します。
各子要素を引数としてブロックを呼び出します。
xpath に文字列を指定するとそれにマッチする子要素のみを対象とします。
@param xpath XPath 文字列 -
REXML
:: Element # each _ element _ with _ attribute(key , value = nil , max = 0 , name = nil) {|element| . . . } -> () (18307.0) -
特定の属性を持つすべての子要素を引数としてブロックを呼び出します。
...字列)
@param max ブロック呼出の対象とする子要素の最大個数
@param name xpath文字列
//emlist[][ruby]{
require 'rexml/document'
doc = REXML::Document.new("<a><b id='1'/><c id='2'/><d id='1'/><e/></a>")
doc.root.each_element_with_attribute('id'){|e| p e }
# >> <b id='1'/>
# >>... -
REXML
:: Element # each _ element _ with _ text(text = nil , max = 0 , name = nil) {|element| . . . } -> () (18307.0) -
テキストを子ノードとして 持つすべての子要素を引数としてブロックを呼び出します。
...字列)
@param max ブロック呼出の対象とする子要素の最大個数
@param name xpath文字列
//emlist[][ruby]{
require 'rexml/document'
doc = REXML::Document.new '<a><b>b</b><c>b</c><d>d</d><e/></a>'
doc.root.each_element_with_text {|e|p e}
# >> <b> ... </>
# >> <c> ... </>
# >> <d> .... -
REXML
:: Element # get _ elements(xpath) -> [REXML :: Element] (18307.0) -
xpath にマッチする要素を配列で返します。
...xpath にマッチする要素を配列で返します。
xpath には XPath 文字列を指定します。
@param xpath XPath 文字列
@see REXML::Elements#to_a... -
REXML
:: Element # get _ text(path = nil) -> REXML :: Text | nil (18307.0) -
先頭のテキスト子ノードを返します。
...ます。
REXML::Text#value も参照してください。
path を渡した場合は、その XPath 文字列で指定される
テキストノードの文字列を返します。
テキストノードがない場合には nil を返します。
@param path XPath文字列
@see REXML::Element#tex......t
//emlist[][ruby]{
require 'rexml/document'
doc = REXML::Document.new "<p>some text <b>this is bold!</b> more text</p>"
# doc.root (<p> ... </p>) は2つのテキストノード("some text " と " more text"
# を持っているが、前者を返す
doc.root.get_text.value # => "some text "
//}... -
REXML
:: Element # has _ attributes? -> bool (18307.0) -
要素が属性を1つ以上持っていれば真を返します。
要素が属性を1つ以上持っていれば真を返します。 -
REXML
:: Element # has _ elements? -> bool (18307.0) -
self が一つでも子要素を持つならば true を返します。
...self が一つでも子要素を持つならば true を返します。
//emlist[][ruby]{
require 'rexml/document'
doc = REXML::Document.new("<a><b/><c>Text</c></a>")
doc.root.has_elements? # => true
doc.elements["/a/b"].has_elements? # => false
# /a/c はテキストノードしか... -
REXML
:: Element # has _ text? -> bool (18307.0) -
要素がテキストノードを子ノードとして持つ場合に true を返します。
要素がテキストノードを子ノードとして持つ場合に true を返します。 -
REXML
:: Element # next _ element -> Element | nil (18307.0) -
次の兄弟要素を返します。
...次の兄弟要素を返します。
次の要素が存在しない場合は nil を返します。
//emlist[][ruby]{
require 'rexml/document'
doc = REXML::Document.new '<a><b/>text<c/></a>'
doc.root.elements['b'].next_element # => <c/>
doc.root.elements['c'].next_element # => nil
//}... -
REXML
:: Element # node _ type -> Symbol (18307.0) -
シンボル :element を返します。
シンボル :element を返します。 -
REXML
:: Element # root _ node -> REXML :: Document | REXML :: Node (18307.0) -
self が属する文書のルートノードを返します。
...素が属する文書(REXML::Document) オブジェクトが
返されます。
その要素が属する REXML::Document オブジェクトが存在しない
場合は木構造上のルートノードが返されます。
//emlist[][ruby]{
require 'rexml/document'
doc = REXML::Document.new(<<EOS)... -
REXML
:: Element # text(path = nil) -> String | nil (18307.0) -
先頭のテキスト子ノードの文字列を返します。
...ます。
REXML::Text#value も参照してください。
path を渡した場合は、その XPath 文字列で指定される
テキストノードの文字列を返します。
テキストノードがない場合には nil を返します。
@param path XPath文字列
@see REXML::Element#get......_text
//emlist[][ruby]{
require 'rexml/document'
doc = REXML::Document.new "<p>some text <b>this is bold!</b> more text</p>"
# doc.root (<p> ... </p>) は2つのテキストノード("some text " と " more text"
# を持っているが、前者を返す
doc.root.text # => "some text "
//}... -
REXML
:: Element # whitespace -> bool (18307.0) -
要素(self)内で空白が考慮されるならば真を返します。
...要素(self)内で空白が考慮されるならば真を返します。
これは、
* REXML::Element#context に :respect_whitespace も :compress_whitespace も
含まれない
* context の :respect_whitespace に self の要素名が含まれていて、
:compress_whitespace に se......のには :all が指定されている場合と、
配列に含まれている場合の両方があります。
のいずれかの場合に真を返します。
要素名として REXML::Namespace#expanded_name が使われるので、
名前空間の prefix は判定に影響します。... -
REXML
:: Element # write(output = $ stdout , indent = -1 , transitive = false , ie _ hack = false) (18307.0) -
このメソッドは deprecated です。 REXML::Formatter を代わりに 使ってください。
...このメソッドは deprecated です。 REXML::Formatter を代わりに
使ってください。
output にその要素を文字列化したものを(子要素を含め)出力します。
@param output 出力先(IO のように << で書き込めるオブジェクト)
@param indent インデ... -
REXML
:: Element # xpath -> String (18307.0) -
文書上の対象の要素にのみマッチする xpath 文字列を返します。
...る xpath 文字列を返します。
//emlist[][ruby]{
require 'rexml/document'
doc = REXML::Document.new('<a><b/><c/></a>')
c = doc.root.elements[2] # <a> .. </a> の中の <c/> 要素
c # => <c/>
c.xpath # => "/a/c"
doc = REXML::Document.new('<a><b/><b/></a>')
b = doc.root.elements[2] # <a> .. <...