るりまサーチ

最速Rubyリファレンスマニュアル検索!
44件ヒット [1-44件を表示] (0.113秒)

別のキーワード

  1. tracer add_filter
  2. logger add
  3. rexml/document add
  4. openssl add_extension
  5. socket ip_add_membership

ライブラリ

クラス

キーワード

検索結果

REXML::Element#add_element(element, attrs = nil) -> Element (18120.0)

子要素を追加します。

...属性

//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 'my-tag', {'attr1'=>'val1', 'attr2'=>'val2'}
# => <my-tag attr1='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::Child#next_sibling=(other) (7.0)

other を 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_sibling = d

p a.to_s # => "<a><d/><b/><c/></a>"
//}...

REXML::Child#previous_sibling=(other) (7.0)

other を 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_sibling = d

p a.to_s # => "<a><d/><b/><c/></a>"
//}...

REXML::Element#text=(text) (7.0)

「先頭の」テキストノードを text で置き換えます。

...nt.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"; doc.to_s # => "<a><b/>Bar</a>"
doc.root.add_element "c"
doc.root.text = "Baz"; doc.to_s # => "<a><b/>Baz<c/></a>"
doc.root.text = nil; doc.to_s # => "<a><b/><c/></a>"
//}...