るりまサーチ

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

別のキーワード

  1. _builtin each
  2. _builtin each_line
  3. prime each
  4. tsort tsort_each

検索結果

<< 1 2 3 > >>

REXML::Elements#each(xpath = nil) {|element| ... } -> [REXML::Elements] (18133.0)

全ての子要素に対しブロックを呼び出します。

...呼び出します。

REXML
::XPath.each などとは異なり、要素以外の
テキストノードなどはすべて無視されることに注意してください。

@param xpath XPath文字列

//emlist[][ruby]{
require 'rexml/document'
require 'rexml/xpath'
doc = REXML::Document.new '<a><b/...
...ブロックに渡される
doc.root.elements.each {|e|p e}
# <b/>, <b/> がブロックに渡される
doc.root.elements.each('b') {|e|p e} #-> Yields b, b elements
# <b/>,<c/>,<d/>,<b/>,<c/>,<d/> がブロックに渡される
doc.root.elements.each('child::node()') {|e|p e}
# <b/>,<c/>,<d/>,"se...
...an",<b/>,<c/>,<d/> がブロックに渡される
REXML
::XPath.each(doc.root, 'child::node()'){|node| p node }
//}...

REXML::Attributes#each {|name, value| ... } -> () (18109.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='2' att='&lt;'/>
</root>
EOS
a = doc.get_elements("/root/a").first

a.attributes.each do |name, value|
p [name, value]
end

# => ["foo:att", "1"]
# => ["bar:att", "2"]
# => ["att", "<"]
//}...

REXML::Parent#each -> Enumerator (18106.0)

各子ノードに対しブロックを呼び出します。

各子ノードに対しブロックを呼び出します。

ブロックを省略した場合は Enumerator を返します。

REXML::Parent#each {|object| ... } -> () (18106.0)

各子ノードに対しブロックを呼び出します。

各子ノードに対しブロックを呼び出します。

ブロックを省略した場合は Enumerator を返します。

REXML::AttlistDecl#each {|name, value| ... } -> () (18103.0)

それぞれの属性名、デフォルト値を引数として ブロックを順に呼び出します。

それぞれの属性名、デフォルト値を引数として
ブロックを順に呼び出します。

デフォルト値を持たない属性に関しては nil が渡されます。

絞り込み条件を変える

REXML::Parsers::PullParser#each {|event| ... } -> () (18103.0)

XMLをパースし、得られたイベント列を引数として順にブロックを呼び出します。

...し、得られたイベント列を引数として順にブロックを呼び出します。

@raise REXML::ParseException XML文書のパースに失敗した場合に発生します
@raise REXML::UndefinedNamespaceException XML文書のパース中に、定義されていない名前空間...

REXML::Element#each_element_with_attribute(key, value = nil, max = 0, name = nil) {|element| ... } -> () (6127.0)

特定の属性を持つすべての子要素を引数としてブロックを呼び出します。

...'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'/>
# >> <c id='2'/>
# >> <d id='1'/>
doc.root.each_element_with_attribute('id', '1'){|e| p e }
# >> <b id='1'/>
# >> <d id='1'/>
doc.root.each...
..._element_with_attribute('id', '1', 1){|e| p e }
# >> <b id='1'/>
doc.root.each_element_with_attribute('id', '1', 0, 'd'){|e| p e }
# >> <d id='1'/>
//}...

REXML::Element#each_element_with_text(text = nil, max = 0, name = nil) {|element| ... } -> () (6127.0)

テキストを子ノードとして 持つすべての子要素を引数としてブロックを呼び出します。

...][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> ... </>
doc.root.each_element_with_text('b'){|e|p e}
# >> <b> ... </>
# >> <c> ... </>
doc.root.each_element_with_text...
...('b', 1){|e|p e}
# >> <b> ... </>
doc.root.each_element_with_text(nil, 0, 'd'){|e|p e}
# >> <d> ... </>
//}...

REXML::Attributes#each_attribute {|attribute| ... } -> () (6109.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...
...o:att='1' bar:att='2' att='&lt;'/>
</root>
EOS
a = doc.get_elements("/root/a").first

a.attributes.each_attribute do |attr|
p [attr.namespace, attr.name, attr.value]
end
# => ["http://example.org/foo", "att", "1"]
# => ["http://example.org/bar", "att", "2"]
# => ["", "att", "<"]
//}...
<< 1 2 3 > >>