るりまサーチ

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

別のキーワード

  1. document root
  2. psych root
  3. pstore root?
  4. pathname root?
  5. rexml/document root

検索結果

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

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

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

...)。

@
param key 属性名(文字列)
@
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.ea...
...| 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 }
# >>...

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

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

...す。

@
param index 取り出したい要素の index (整数)もしくは xpath (文字列)
@
param name 子要素の名前(文字列)

//emlist[][ruby]{
require '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> ... </>
//}...

PStore#delete(name) -> object (43.0)

ルートnameに対応する値を削除します。

...

@
param name 探索するルート。

@
return 削除した値を返します。

@
raise PStore::Error トランザクション外でこのメソッドが呼び出された場合に発生します。

例:

require 'pstore'
db = PStore.new("/tmp/foo")
db.transaction do
p db.roots...
...# => []
ary = db["root"] = [1,2,3,4]
ary[0] = [1,1.5]
end

db.transaction do |pstore|
pstore.delete("root") # => [[1, 1.5], 2, 3, 4]
pstore.delete("root") # => nil
end

@
see Hash#delete...

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

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

...ありません)。

@
param text テキストの中身(文字列)
@
param max ブロック呼出の対象とする子要素の最大個数
@
param name xpath文字列

//emlist[][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::Element#text=(text) (37.0)

「先頭の」テキストノードを text で置き換えます。

...削除されます。

@
param text 置き換え後のテキスト(文字列、REXML::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><b/>Baz<c/></a>"
doc.root.text = nil; doc.to_s # => "<a><b/><c/></a>"
//}...

絞り込み条件を変える

REXML::StreamListener#doctype(name, pub_sys, long_name, uri) -> () (37.0)

文書型宣言(DTD)をパースしたときに呼び出されるコールバックメソッドです。

...している場合には nil が渡されます。

@
param name 宣言されているルート要素名が文字列で渡されます。
@
param pub_sys "PUBLIC" もしくは "SYSTEM" が渡されます。nilが渡される場合もあります。
@
param long_name "SYSTEM" の場合はシステム識...
...
@
param uri "SYSTEM" の場合は nil が、"PUBLIC" の場合はシステム識別子が渡されます

=== 例
<!DOCTYPE me PUBLIC "foo" "bar">
というDTDに対しては
name: "me"
pub_sys: "PUBLIC"
long_name: "foo"
uri: "bar"
という引数が渡されます。
<!DOCTYPE root [...
......
というDTDに対しては
name: "root"
pub_sys: nil
long_name: nil
uri: nil
という引数が渡されます。...

PStore#transaction(read_only = false) {|pstore| ... } -> object (31.0)

トランザクションに入ります。 このブロックの中でのみデータベースの読み書きができます。

...み専用のトランザクションが使用可能です。

@
param read_only 真を指定すると、読み込み専用のトランザクションになります。

@
return ブロックで最後に評価した値を返します。

@
raise PStore::Error read_only を真にしたときに、デー...
...した場合に発生します。

例:

require 'pstore'
db = PStore.new("/tmp/foo")
db.transaction do
p db.roots # => []
ary = db["root"] = [1,2,3,4]
ary[0] = [1,1.5]
end

db.transaction(true) do |pstore|
pstore["root"] = 'aaa' # => ここで例外発生
end...

REXML::Attributes#get_attribute(name) -> Attribute | nil (31.0)

name という名前の属性を取得します。

...します。

@
param name 属性名(文字列)
@
see REXML::Attributes#[]

//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.ge...
...t_elements("/root/a").first

a.attributes.get_attribute("att") # => att='&lt;'
a.attributes.get_attribute("foo:att") # => foo:att='1'
//}...

REXML::Attributes#get_attribute_ns(namespace, name) -> REXML::Attribute | nil (31.0)

namespace と name で特定される属性を返します。

...

@
param namespace 名前空間(URI, 文字列)
@
param 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.get_attribute_ns("", "att") # => att='&lt;'
a.attributes.get_attribute_ns("http://example.org/foo", "att") # => foo:att='1'
a.attributes.get_attribute_ns("http://example.org/baz", "att") # => nil
a.attributes.get_attribute_ns("http://example.org/fo...
<< < 1 2 3 4 5 ... > >>