33件ヒット
[1-33件を表示]
(0.109秒)
ライブラリ
-
rexml
/ document (33)
クラス
-
REXML
:: Attributes (22) -
REXML
:: Element (11)
キーワード
-
each
_ attribute (11) -
each
_ element _ with _ attribute (11)
検索結果
先頭3件
-
REXML
:: Attributes # each _ attribute {|attribute| . . . } -> () (27545.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='2' att='<'/>
</root>
EOS
a = doc.get_elements("/r......oot/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", "<"]
//}... -
REXML
:: Attributes # each {|name , value| . . . } -> () (27207.0) -
各属性の名前と値に対しブロックを呼び出します。
...d_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='<'/>
</root>
EOS
a = doc.get_elements("/r......oot/a").first
a.attributes.each do |name, value|
p [name, value]
end
# => ["foo:att", "1"]
# => ["bar:att", "2"]
# => ["att", "<"]
//}... -
REXML
:: Element # each _ element _ with _ attribute(key , value = nil , max = 0 , name = nil) {|element| . . . } -> () (24550.0) -
特定の属性を持つすべての子要素を引数としてブロックを呼び出します。
...を呼び出します。
key で指定した属性名の属性を持つ要素のみを対象とします。
value を指定すると、keyで指定した属性名を持つ属性の値がvalueである
もののみを対象とします。
maxを指定すると、対象となる子要素の先頭 max......)
@param value 属性値(文字列)
@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|......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'/>
//}...