種類
- インスタンスメソッド (58)
- 特異メソッド (7)
- クラス (5)
クラス
-
REXML
:: Attribute (3) -
REXML
:: Attributes (13) -
REXML
:: CData (3) -
REXML
:: Child (2) -
REXML
:: DocType (4) -
REXML
:: Document (1) -
REXML
:: Element (21) -
REXML
:: Elements (9) -
REXML
:: Entity (1) -
REXML
:: Instruction (1) -
REXML
:: Text (4) -
REXML
:: XPath (3)
キーワード
- << (1)
- Default (1)
- ExternalEntity (1)
- NotationDecl (1)
- Pretty (1)
- Transitive (1)
- [] (2)
- []= (2)
- add (1)
-
add
_ attribute (2) -
add
_ attributes (1) -
add
_ element (1) -
add
_ namespace (2) - attribute (1)
-
attribute
_ of (1) -
attributes
_ of (1) - delete (2)
-
delete
_ all (2) -
delete
_ attribute (1) -
delete
_ element (1) -
delete
_ namespace (1) - each (3)
-
each
_ attribute (1) -
each
_ element _ with _ attribute (1) -
each
_ element _ with _ text (1) -
external
_ id (1) - first (1)
-
get
_ attribute (1) -
get
_ attribute _ ns (1) -
get
_ text (1) -
has
_ elements? (1) - length (1)
- match (1)
- matches? (1)
- namespace (2)
- namespaces (2)
- new (2)
-
next
_ element (1) -
next
_ sibling= (1) - prefix (1)
- prefixes (2)
-
previous
_ sibling= (1) - size (2)
-
stand
_ alone? (1) - target (1)
- text (1)
- text= (1)
-
to
_ a (2) -
to
_ s (1) -
to
_ string (1) - unnormalize (1)
- value (2)
- value= (1)
- write (1)
- xpath (1)
検索結果
先頭5件
-
REXML
:: Text # value=(val) (64459.0) -
テキストの内容を val に変更します。
...al には非正規化された(エスケープされていない)文字列を渡さなければ
なりません。
//emlist[][ruby]{
require 'rexml/document'
e = REXML::Element.new("a")
e.add_text("foo")
e[0].value = "bar"
e.to_s # => "<a>bar</a>"
e[0].value = "<a>"
e.to_s # => "<a><a></a>"
/... -
REXML
:: Element # each _ element _ with _ text(text = nil , max = 0 , name = nil) {|element| . . . } -> () (64423.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> ... </>
# >... -
REXML
:: Text . unnormalize(string , doctype = nil , filter = nil , illegal = nil) -> String (64225.0) -
string を非正規化(すべての entity をアンエスケープ)したものを 返します。
string を非正規化(すべての entity をアンエスケープ)したものを
返します。
filter でアンエスケープしない実体の実体名を文字列配列で指定します。
@param string 非正規化する文字列
@param doctype DTD(REXML::DocType オブジェクト)
@param filter アンエスケープしない実体の実体名(文字列配列)
@param illegal 内部用。使わないでください。
//emlist[][ruby]{
require 'rexml/text'
REXML::Text.unnormalize("& &foobar; ... -
REXML
:: DocType # external _ id -> String | nil (63925.0) -
DTD が外部サブセットを用いている場合は "SYSTEM", "PUBLIC" の いずれかの文字列を返します。
..."SYSTEM", "PUBLIC" の
いずれかの文字列を返します。
それ以外の場合は 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/... -
REXML
:: Text # value -> String (63925.0) -
テキストの内容を非正規化(すべての実体をアンエスケープ)された状態で返します。
...。
このメソッドの返り値では raw モードや entity_filter は無視されます。
@see REXML::Text#raw, REXML::Text#to_s
//emlist[][ruby]{
require 'rexml/document'
t = REXML::Text.new("< & foobar", false, nil, false)
t.to_s # => "< & foobar"
t.value # => "< & foobar"
//}... -
REXML
:: ExternalEntity (63025.0) -
DTD 内の宣言でパラメータ実体参照を使って宣言が されているものを表わすクラスです。
...<!ENTITY % HTMLsymbol PUBLIC
"-//W3C//ENTITIES Symbols for XHTML//EN"
"xhtml-symbol.ent">
%HTMLsymbol;
//emlist[][ruby]{
require 'rexml/document'
doctype = REXML::Document.new(<<EOS).doctype
<!DOCTYPE xhtml [
<!ENTITY % HTMLsymbol PUBLIC
"-//W3C//ENTITIES Symbols for XHTML//EN"... -
REXML
:: Element # delete _ element(element) -> REXML :: Element (56659.0) -
子要素を削除します。
...場合はそのうち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'/><d/><c/></a>"
doc.de... -
REXML
:: Element # add _ element(element , attrs = nil) -> Element (56251.0) -
子要素を追加します。
...された要素です。
@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_ele... -
REXML
:: Elements # delete _ all(xpath) -> [REXML :: Element] (55597.0) -
xpath で指定した XPath 文字列にマッチする要素をすべて取り除きます。
...チする要素をすべて取り除きます。
@param xpath 取り除く要素を指し示す XPath 文字列
//emlist[][ruby]{
require 'rexml/document'
doc = REXML::Document.new('<a><c/><c/><c/><c/></a>')
doc.elements.delete_all("a/c") # => [<c/>, <c/>, <c/>, <c/>]
doc.to_s... -
REXML
:: Element # delete _ namespace(namespace = "xmlns") -> self (55579.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.delet... -
REXML
:: Element # delete _ attribute(key) -> REXML :: Attribute | nil (55423.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 # => <E x='foo' y:x='bar'/>
e.de... -
REXML
:: Element # each _ element _ with _ attribute(key , value = nil , max = 0 , name = nil) {|element| . . . } -> () (55423.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
:: Attributes # get _ attribute _ ns(namespace , name) -> REXML :: Attribute | nil (55351.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... -
REXML
:: Attributes # get _ attribute(name) -> Attribute | nil (55315.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 foo:att='1' bar:at... -
REXML
:: Attributes # delete _ all(name) -> [REXML :: Attribute] (55033.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=... -
REXML
:: Element # has _ elements? -> bool (55015.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
:: Attributes # namespaces -> { String => String } (54997.0) -
self の中で宣言されている名前空間の集合を返します。
...返します。
返り値は名前空間の prefix をキーとし、URI を値とする
Hash を返します。
//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=... -
REXML
:: Element # namespaces -> {String => String} (54961.0) -
self の文脈で定義されている名前空間の情報を返します。
...定義されている名前空間を、{ prefix => 識別子 }
というハッシュテーブルで返します。
//emlist[][ruby]{
require 'rexml/document'
doc = REXML::Document.new("<a xmlns:x='1' xmlns:y='2'><b/><c xmlns:z='3'/></a>")
doc.elements['//b'].namespaces # => {"x"=>"1", "y"=>"2"}
//}... -
REXML
:: Document # stand _ alone? -> String (54943.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
:: CData # value -> String (54925.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
:: Attributes # each _ attribute {|attribute| . . . } -> () (54697.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 foo:att='1' bar:att=... -
REXML
:: Formatters :: Default (54043.0) -
XMLドキュメントを(文字列として)出力するクラスです。
...ML::Formatters::Pretty と
異なりテキストの改行や空白を修正せずにそのまま出力します。
//emlist[][ruby]{
require 'rexml/document'
require 'rexml/formatters/default'
doc = REXML::Document.new <<EOS
<root>
<children>
<grandchildren/>
</children>
</root>
EOS
default_form... -
REXML
:: NotationDecl (54025.0) -
DTD の記法宣言を表すクラスです。
...DTD の記法宣言を表すクラスです。
//emlist[][ruby]{
require 'rexml/document'
doctype = REXML::Document.new(<<EOS).doctype
<!DOCTYPE foo [
<!NOTATION type-image-svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<!NOTATION type-image-g... -
REXML
:: Attributes # delete(attribute) -> REXML :: Element (46705.0) -
指定した属性を取り除きます。
...を返します。
@param attribute 取り除く属性(文字列もしくは 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 foo:att='1' bar:at... -
REXML
:: XPath . each(element , path = nil , namespaces = {} , variables = {}) {|e| . . . } -> () (46618.0) -
element の path で指定した XPath 文字列にマッチする各ノード に対してブロックを呼び出します。
...文字列
@param namespace 名前空間とURLの対応付け
@param variables 変数名とその値の対応付け
//emlist[][ruby]{
require 'rexml/document'
doc = REXML::Document.new(<<EOS)
<root xmlns:x='1'>
<a>
<b>b1</b>
<x:c />
<b>b2</b>
<d />
</a>
<b> b3 </b>
</root>
EOS... -
REXML
:: XPath . match(element , path = nil , namespaces = {} , variables = {}) -> [Node] (46579.0) -
element の path で指定した XPath 文字列にマッチするノードの配列を 返します。
...文字列
@param namespace 名前空間とURLの対応付け
@param variables 変数名とその値の対応付け
//emlist[][ruby]{
require 'rexml/document'
doc = REXML::Document.new(<<EOS)
<root xmlns:x='1'>
<a>
<b>b1</b>
<x:c />
<b>b2</b>
<d />
</a>
<b> b3 </b>
</root>
EOS... -
REXML
:: Element # attribute(name , namespace = nil) -> REXML :: Attribute | nil (46351.0) -
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=... -
REXML
:: DocType # attribute _ of(element , attribute) -> String | nil (46225.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... -
REXML
:: DocType # attributes _ of(element) -> [REXML :: Attribute] (46225.0) -
DTD 内の属性リスト宣言で、 element という名前の要素に対し宣言されている 属性の名前とデフォルト値を REXML::Attribute の配列で返します。
...、各 Attribute オブジェクトの
REXML::Attribute#name と
REXML::Attribute#value で表現されます。
//emlist[][ruby]{
require 'rexml/document'
doctype = REXML::Document.new(<<EOS).doctype
<!DOCTYPE books [
<!ELEMENT book (comment)>
<!ELEMENT comment (#PCDATA)>
<!ATTLIST book... -
REXML
:: Element # add _ attribute(key , value) -> () (46123.0) -
要素の属性を追加します。 同じ名前の属性がすでにある場合はその属性を新しい 属性で置き換えます。
...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 # =... -
REXML
:: Element # add _ namespace(prefix , uri) -> self (46105.0) -
名前空間を要素に追加します。
...る場合はそれが上書きされます。
@param prefix 名前空間の prefix
@param uri 名前空間の uri
//emlist[][ruby]{
require 'rexml/document'
a = REXML::Element.new("a")
a.add_namespace("xmlns:foo", "bar" )
a.add_namespace("foo", "bar") # 上と同じ意味
a.add_namespace("twiddle... -
REXML
:: Elements # each(xpath = nil) {|element| . . . } -> [REXML :: Elements] (46087.0) -
全ての子要素に対しブロックを呼び出します。
...ストノードなどはすべて無視されることに注意してください。
@param xpath XPath文字列
//emlist[][ruby]{
require 'rexml/document'
require 'rexml/xpath'
doc = REXML::Document.new '<a><b/><c/><d/>sean<b/><c/><d/></a>'
# <b/>,<c/>,<d/>,<b/>,<c/>, <d/> がブロックに渡... -
REXML
:: Attribute # namespace(arg = nil) -> String | nil (46015.0) -
属性の名前空間の URI を返します。
...間でなく、arg という名前空間
の URI が返されます。
通常は省略します。
//emlist[][ruby]{
require 'rexml/document'
e = REXML::Element.new("el")
e.add_attribute("xmlns:ns", "http://www.example.com/ns")
e.add_attribute("ns:r", "rval")
p e.attributes.get_attrib... -
REXML
:: Attributes # each {|name , value| . . . } -> () (45997.0) -
各属性の名前と値に対しブロックを呼び出します。
...ックを呼び出します。
名前には expanded_name(REXML::Namespace#exapnded_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='... -
REXML
:: Element # namespace(prefix=nil) -> String (45961.0) -
self の文脈で prefix が指している名前空間の URI を返します。
...返します。
prefix で指示される名前空間の宣言が存在しない場合は nil を返します。
//emlist[][ruby]{
require 'rexml/document'
doc = REXML::Document.new("<a xmlns='1' xmlns:y='2'><b/><c xmlns:z='3'/><y:d /></a>")
b = doc.elements['//b']
b.namespace # => "1"
b.name... -
REXML
:: Element # next _ element -> Element | nil (45961.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
:: Entity . matches?(string) -> bool (45925.0) -
string が実体宣言の文法に従う文字列であれば真を返します。
...実体宣言の文法に従う文字列であれば真を返します。
@param string 判定対象の文字列
//emlist[][ruby]{
require 'rexml/document'
p REXML::Entity.matches?('<!ENTITY s "seal">') # => true
p REXML::Entity.matches?('<!ENTITY % s "seal">') # => true
p REXML::Entity.matches?('... -
REXML
:: Element # add _ attributes(attrs) -> () (45877.0) -
要素の属性を複数追加します。 同じ名前の属性がすでにある場合はその属性を新しい 属性で置き換えます。
...属性を指定します。
@param attrs 追加する属性の属性名と属性値の対の集合(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([... -
REXML
:: Element # add _ attribute(attr) -> () (45823.0) -
要素の属性を追加します。 同じ名前の属性がすでにある場合はその属性を新しい 属性で置き換えます。
...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 # =... -
REXML
:: Element # add _ namespace(uri) (45805.0) -
名前空間を要素に追加します。
...る場合はそれが上書きされます。
@param prefix 名前空間の prefix
@param uri 名前空間の uri
//emlist[][ruby]{
require 'rexml/document'
a = REXML::Element.new("a")
a.add_namespace("xmlns:foo", "bar" )
a.add_namespace("foo", "bar") # 上と同じ意味
a.add_namespace("twiddle... -
REXML
:: Child # next _ sibling=(other) (45733.0) -
other を self の次の隣接ノードとします。
...ドが持つ子ノード列の self の後ろに
other を挿入します。
@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_sibli... -
REXML
:: Attributes # length -> Integer (45697.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
:: Instruction # target -> String (45625.0) -
XML 処理命令のターゲットを返します。
...XML 処理命令のターゲットを返します。
//emlist[][ruby]{
require 'rexml/document'
doc = REXML::Document.new(<<EOS)
<?xml version="1.0" encoding="utf-8" ?>
<?xml-stylesheet type="text/css" href="style.css"?>
<root />
EOS
doc[2] # => <?p-i xml-stylesheet ...?>
doc[2].target # => "xml-st... -
REXML
:: Formatters :: Transitive (45043.0) -
XMLドキュメントをテキストの内容を変えずに 多少の整形を加えて出力するクラスです。
...にたつかもしれません。
ただ、ほとんどの場合は奇妙な出力結果になるでしょう。
//emlist[][ruby]{
require 'rexml/document'
require 'rexml/formatters/transitive'
doc = REXML::Document.new <<EOS
<root><children>
<grandchildren foo='bar' />
</children></root>
EOS
tran... -
REXML
:: Elements # delete(element) -> Element (37987.0) -
element で指定した子要素を取り除きます。
...けることに注意してください。
@param element 削除する要素(REXML::Element, 整数, 文字列)
//emlist[][ruby]{
require 'rexml/document'
doc = REXML::Document.new '<a><b/><c/><c id="1"/></a>'
b = doc.root.elements[1]
doc.root.elements.delete b # => <b/>
doc.root.to_s... -
REXML
:: Text . new(arg , respect _ whitespace = false , parent = nil , raw = nil , entity _ filter = nil , illegal = REXML :: Text :: NEEDS _ A _ SECOND _ CHECK) (37228.0) -
テキストノードオブジェクトを生成します。
...L::Text.new("<&", false, nil, true).to_s # parse error
//}
//emlist[doctype があり、実体が宣言されている場合][ruby]{
require 'rexml/document'
doc = REXML::Document.new(<<EOS)
doctype = REXML::Document.new(<<EOS).doctype
<!DOCTYPE root [
<!ENTITY p "foobar publisher">
<!ENTITY % q "q... -
REXML
:: Elements # to _ a(xpath = nil) -> [REXML :: Element] (37018.0) -
すべての子要素の配列を返します。
...XPath.match などと
異なり、要素以外の子ノードは無視されます。
@param xpath XPath文字列
//emlist[][ruby]{
require 'rexml/document'
require 'rexml/xpath'
doc = REXML::Document.new '<a>sean<b/>elliott<c/></a>'
doc.root.elements.to_a # => [<b/>, <c/>]
doc.root.elements.to_... -
REXML
:: CData . new(text , respect _ whitespace = true , parent = nil) -> REXML :: CData (36925.0) -
text をテキストとして持つ CData オブジェクトを生成します。
...字列
@param respect_whitespace 空白を保存するかどうかを決める真偽値
@param parent 親ノード
//emlist[][ruby]{
require 'rexml/document'
doc = REXML::Document.new(<<EOS)
<root />
EOS
doc.root.add(REXML::CData.new("foo bar baz "))
doc.to_s # => "<root><![CDATA[foo bar baz ]]><... -
REXML
:: Element # get _ text(path = nil) -> REXML :: Text | nil (36925.0) -
先頭のテキスト子ノードを返します。
...ストノードがない場合には nil を返します。
@param path XPath文字列
@see REXML::Element#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 tex... -
REXML
:: Element # text(path = nil) -> String | nil (36925.0) -
先頭のテキスト子ノードの文字列を返します。
...トノードがない場合には 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 te... -
REXML
:: Element # text=(text) (36841.0) -
「先頭の」テキストノードを text で置き換えます。
...ードが削除されます。
@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>"
doc.root.text = "Bar... -
REXML
:: Child # previous _ sibling=(other) (36733.0) -
other を self の前の隣接ノードとします。
...ードが持つ子ノード列の self の前に
other を挿入します。
@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_sibli... -
REXML
:: Attributes # to _ a -> [Attribute] (36664.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
:: Element # xpath -> String (36505.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... -
REXML
:: Attribute # prefix -> String (36487.0) -
属性の名前空間を返します。
...属性の名前空間を返します。
//emlist[][ruby]{
require 'rexml/document'
e = REXML::Element.new( "elns:myelement" )
e.add_attribute( "nsa:a", "aval" )
e.add_attribute( "b", "bval" )
p e.attributes.get_attribute( "a" ).prefix # -> "nsa"
p e.attributes.get_attribute( "b" ).prefix # -> "... -
REXML
:: Attributes # prefixes -> [String] (36397.0) -
self の中で宣言されている prefix の集合を 文字列の配列で返します。
...返します。
self が属する要素より上位の要素で定義されているものは含みません。
//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='... -
REXML
:: Attributes # size -> Integer (36397.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
:: Formatters :: Pretty (36043.0) -
XMLドキュメントを(文字列として)見た目良く出力するクラスです。
...Formatters::Default と
異なり見た目のためテキストの改行や空白を修正して出力します。
//emlist[][ruby]{
require 'rexml/document'
require 'rexml/formatters/pretty'
doc = REXML::Document.new <<EOS
<root>
<children>
<grandchildren foo='bar'/>
</children>
</root>
EOS
pre... -
REXML
:: Elements # add(element = nil) -> REXML :: Element (28705.0) -
要素 element を追加します。
...の要素が追加されます。
追加された要素が返されます。
@param element 追加する要素
//emlist[][ruby]{
require 'rexml/document'
a = REXML::Element.new('a')
a.elements.add(REXML::Element.new('b')) # => <b/>
a.to_s # => "<a><b/></a>"
a.elements.add('c') # => <c/>
a.to_s #... -
REXML
:: XPath . first(element , path = nil , namespaces = {} , variables = {}) -> Node | nil (28405.0) -
element の path で指定した XPath 文字列にマッチする最初のノードを 返します。
...文字列
@param namespace 名前空間とURLの対応付け
@param variables 変数名とその値の対応付け
//emlist[][ruby]{
require 'rexml/document'
doc = REXML::Document.new(<<EOS)
<root xmlns:x='1'>
<a>
<b>b1</b>
<x:c />
<b>b2</b>
<d />
</a>
<b> b3 </b>
</root>
EOS... -
REXML
:: DocType # write(output , indent = 0 , transitive = false , ie _ hack = false) -> () (28225.0) -
output に DTD を出力します。
...ます。指定しないでください。
@param ie_hack 無視されます。指定しないでください。
//emlist[][ruby]{
require 'rexml/document'
doctype = REXML::Document.new(<<EOS).doctype
<!DOCTYPE books [
<!ELEMENT book (comment)>
<!ELEMENT comment (#PCDATA)>
<!ATTLIST book... -
REXML
:: Attributes # []=(name , value) (28051.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=... -
REXML
:: Attributes # [](name) -> String | nil (28015.0) -
属性名nameの属性値を返します。
...い。
nameという属性名の属性がない場合は nil を返します。
@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... -
REXML
:: Element # prefixes -> [String] (27361.0) -
self の文脈で定義されている prefix を文字列の配列を返します。
...字列の配列を返します。
対象の要素とその外側の要素で定義されている prefix を返します。
//emlist[][ruby]{
require 'rexml/document'
doc = REXML::Document.new("<a xmlns:x='1' xmlns:y='2'><b/><c xmlns:z='3'/></a>")
doc.elements['//b'].prefixes # => ["x", "y"]
//}... -
REXML
:: Elements # size -> Integer (27361.0) -
保持している要素の個数を返します。
...保持している要素の個数を返します。
//emlist[][ruby]{
require 'rexml/document'
doc = REXML::Document.new '<a>sean<b/>elliott<b/>russell<b/></a>'
# doc.root は3つの要素と3つのテキストノードを持つため、6を返す
doc.root.size # => 6
# そのうち要... -
REXML
:: Attribute # to _ string -> String (27079.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
:: CData # to _ s -> String (27025.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
:: Elements # <<(element = nil) -> REXML :: Element (19405.0) -
要素 element を追加します。
...の要素が追加されます。
追加された要素が返されます。
@param element 追加する要素
//emlist[][ruby]{
require 'rexml/document'
a = REXML::Element.new('a')
a.elements.add(REXML::Element.new('b')) # => <b/>
a.to_s # => "<a><b/></a>"
a.elements.add('c') # => <c/>
a.to_s #... -
REXML
:: Elements # [](index , name = nil) -> REXML :: Element | nil (19405.0) -
index が指し示している要素を返します。
...取り出したい要素の index (整数)もしくは xpath (文字列)
@param name 子要素の名前(文字列)
//emlist[][ruby]{
require 'rexml/document'
doc = REXML::Document.new '<a><b/><c id="1"/><c id="2"/><d/></a>'
doc.root.elements[1] # => <b/>
doc.root.elements['c'] # => <c id=... -
REXML
:: Elements # []=(index , element) (18751.0) -
集合に要素 element を追加/更新します。
...されます。
@param index 要素を更新する位置
@param element 要素(REXML::Elementオブジェクト)
//emlist[][ruby]{
require 'rexml/document'
doc = REXML::Document.new '<a/>'
doc.root.elements[10] = REXML::Element.new('b')
doc.root.to_s # => "<a><b/></a>"
doc.root.elements[1] # => <b...