るりまサーチ

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

別のキーワード

  1. rexml/document new
  2. rexml/document write
  3. rexml/document to_s
  4. rexml/document clone
  5. rexml/document node_type

検索結果

<< < ... 2 3 4 5 6 ... > >>

REXML::Element#each_element_with_attribute(key, value = nil, max = 0, name = nil) {|element| ... } -> () (36.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| ... } -> () (36.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::Elements#each(xpath = nil) {|element| ... } -> [REXML::Elements] (36.0)

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

...ist[][ruby]{
require 'rexml/document'
require 'rexml/xpath'
doc = REXML::Document.new '<a><b/><c/><d/>sean<b/><c/><d/></a>'
# <b/>,<c/>,<d/>,<b/>,<c/>, <d/> がブロックに渡される
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/>,"sean",<b/>,<c/>,<d/> がブロックに渡される
REXML::XPath.each(doc.root, 'child::node()'){|node| p node }
//}...

REXML::Formatters::Pretty (36.0)

XMLドキュメントを(文字列として)見た目良く出力するクラスです。

...re 'rexml/document'
require 'rexml/formatters/pretty'
doc = REXML::Document.new <<EOS
<root>
<children>
<grandchildren foo='bar'/>
</children>
</root>
EOS

pretty_formatter = REXML::Formatters::Pretty.new
output = StringIO.new
pretty_formatter.write(doc, output)
output.string
# => "<root>\n <chil...
...dren>\n <grandchildren foo='bar'/>\n </children>\n</root>"
# この出力結果は入力のXMLよりも空白が増えている
//}...

ReFe (36.0)

ReFe ReFeについては http://i.loveruby.net/ja/prog/refe.html をご覧ください。

...

tar xvzf refe-x.x.x.tar.gz
cd refe-x.x.x
ruby setup.rb config
ruby setup.rb setup
(必要に応じて root になってください)
ruby setup.rb install

(2) http://www.ruby-lang.org/ja/man/man-rd-ja.tar.gz
にあるのが最新のリファ...
...に応じて root になってください)
mkrefe_rubyrefm -d /usr/local/share/refe *.rd

/usr/local/share/refe 下に以下のディレクトリとファイルができます。

class_document/ method_document/
class_document_comp method_document_comp

(4)...

絞り込み条件を変える

REXML::Attributes#[](name) -> String | nil (30.0)

属性名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

p a.attributes["att"] # => "<"
p...

REXML::Attributes#[]=(name, value) (30.0)

指定した属性を更新します。

...ます。

//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["att"] = "9"
a.attribu...

REXML::Attributes#delete(attribute) -> REXML::Element (30.0)

指定した属性を取り除きます。

...ェクト)

//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.delete("att") # =...

REXML::Attributes#delete_all(name) -> [REXML::Attribute] (30.0)

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.delete_all("att") # =>...
<< < ... 2 3 4 5 6 ... > >>