るりまサーチ

最速Rubyリファレンスマニュアル検索!
727件ヒット [201-300件を表示] (0.020秒)
トップページ > クエリ:element[x] > クエリ:Document[x]

別のキーワード

  1. cgi element_init
  2. cgi/html element_init
  3. matrix element
  4. element add_namespace
  5. rexml/document element

検索結果

<< < 1 2 3 4 5 ... > >>

REXML::Elements#[](index, name = nil) -> REXML::Element | nil (3119.0)

index が指し示している要素を返します。

...uire '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='1'/>
doc.root.elements[2,'c'] # => <c id='2'/>

doc = REXML::Document.new '<a><b><c /><a id="1"/></b></a>'
doc.root.elements["a"]...
...# => nil
doc.root.elements["b/a"] # => <a id='1'/>
doc.root.elements["/a"] # => <a> ... </>
//}...

REXML::Element#root -> REXML::Element (3113.0)

self が属する文書のルート要素を返します。

...[][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 # => "root"
grandchildren = doc.get_elements("/root/children/grandch...

REXML::Elements#delete_all(xpath) -> [REXML::Element] (3113.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 # => "<a/>"
//}...

REXML::Elements#to_a(xpath = nil) -> [REXML::Element] (3113.0)

すべての子要素の配列を返します。

...REXML::Elements#each と同様、REXML::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_a("child::node()") # => [<b/>, <c/>]
REXML::XPath.match(doc.root, "child::node()") # => ["sean", <b/>, "elliott", <c/>]
//}...

REXML::Document#root -> REXML::Element | nil (3101.0)

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

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

文書がルート要素を持たない場合は nil を返します。

絞り込み条件を変える

REXML::Element#add_attributes(attrs) -> () (3018.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#get_text(path = nil) -> REXML::Text | nil (3018.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つのテキストノー...

REXML::Element#text(path = nil) -> String | nil (3018.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つのテキストノー...

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

「先頭の」テキストノードを 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"; doc.to_s # => "<a><b/>Bar</a>"
doc.root.add_element "c"
doc.root.text = "Baz"; doc.to_s # => "<a>...
<< < 1 2 3 4 5 ... > >>