るりまサーチ

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

別のキーワード

  1. _builtin to_r
  2. open3 pipeline_r
  3. matrix elements_to_r
  4. fileutils rm_r
  5. bigdecimal to_r

検索結果

REXML::XPath.each(element, path = nil, namespaces = {}, variables = {}) {|e| ... } -> () (21321.0)

element の path で指定した XPath 文字列にマッチする各ノード に対してブロックを呼び出します。

...

namespace
で名前空間の対応付けを Hash で指定します。

variable で XPath 内の変数に対応する値を指定できます。
XPathインジェクション攻撃を避けるため、適切な
エスケープを付加するため、に用います。

@param element 要素(REXML...
...::Element)
@param path XPath文字列
@param namespace 名前空間とURLの対応付け
@param variables 変数名とその値の対応付け

//emlist[][ruby]{
r
equire '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

R
EXML::XPath.each(doc, "/root/a/b"){|e| p e.text }
# >> "b1"
# >> "b2"
//}...

REXML::Attributes#each {|name, value| ... } -> () (21115.0)

各属性の名前と値に対しブロックを呼び出します。

...ame(REXML::Namespace#exapnded_name)が
渡されます。

//emlist[][ruby]{
r
equire '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::Attributes#each_attribute {|attribute| ... } -> () (12315.0)

各属性に対しブロックを呼び出します。

... REXML::Attribute オブジェクトで渡されます。

//emlist[][ruby]{
r
equire '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_attribute do |attr|
p [attr.namespace, attr.name, attr.value]
end
# => ["http://example.org/foo", "att", "1"]
# => ["http://example.org/bar", "att", "2"]
# => ["", "att", "<"]
//}...