143件ヒット
[1-100件を表示]
(0.051秒)
種類
- インスタンスメソッド (121)
- ライブラリ (11)
- 特異メソッド (11)
ライブラリ
-
rexml
/ document (132)
クラス
-
REXML
:: Attributes (88) -
REXML
:: Element (33) -
REXML
:: XPath (11)
キーワード
- [] (11)
- []= (11)
- attribute (11)
-
delete
_ all (11) - each (11)
-
each
_ attribute (11) -
get
_ attribute (11) -
get
_ attribute _ ns (11) - namespaces (11)
- rdoc (11)
-
root
_ node (11)
検索結果
先頭5件
- REXML
:: XPath . first(element , path = nil , namespaces = {} , variables = {}) -> Node | nil - REXML
:: Element # root -> REXML :: Element - REXML
:: Element # root _ node -> REXML :: Document | REXML :: Node - REXML
:: Attributes # namespaces -> { String => String } - REXML
:: Element # attribute(name , namespace = nil) -> REXML :: Attribute | nil
-
REXML
:: XPath . first(element , path = nil , namespaces = {} , variables = {}) -> Node | nil (18267.0) -
element の path で指定した XPath 文字列にマッチする最初のノードを 返します。
...のルート要素からの
位置でマッチするノードを探します。
path を省略すると "*" を指定したことになります。
namespace で名前空間の対応付けを指定します。
variable で XPath 内の変数に対応する値を指定できます。
XPathインジ......am namespace 名前空間とURLの対応付け
@param variables 変数名とその値の対応付け
//emlist[][ruby]{
require '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
a = doc.root........ </>
b1 = REXML::XPath.first(a, "b")
b1.text # => "b1"
REXML::XPath.first(doc, "/root/a/x:c") # => <x:c/>
REXML::XPath.first(a, "x:c") # => <x:c/>
REXML::XPath.first(a, "y:c") # => nil
REXML::XPath.first(a, "y:c", {"y" => "1"}) # => <x:c/>
b2 = REXML::XPath.first(doc, "/root/a/b[text()=$v]", {}, {... -
REXML
:: Element # root -> REXML :: Element (18185.0) -
self が属する文書のルート要素を返します。
...ument.new(<<EOS)
<root>
<children>
<grandchildren />
</children>
</root>
EOS
children = doc.get_elements("/root/children").first
children.name # => "children"
children.root.name # => "root"
grandchildren = doc.get_elements("/root/children/grandchildren").first
grandchildren.name # => "grandchildr......en"
grandchildren.root.name # => "root"
//}... -
REXML
:: Element # root _ node -> REXML :: Document | REXML :: Node (6161.0) -
self が属する文書のルートノードを返します。
...ent.new(<<EOS)
<root>
<children>
<grandchildren />
</children>
</root>
EOS
children = doc.get_elements("/root/children").first
children.name # => "children"
children.root_node == doc # => true
grandchildren = doc.get_elements("/root/children/grandchildren").first
grandchildren.name # => "grandchi......ldren"
grandchildren.root_node == doc # => true
//}... -
REXML
:: Attributes # namespaces -> { String => String } (6130.0) -
self の中で宣言されている名前空間の集合を返します。
...<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("/root/a").first
p doc.root.attributes.namespaces
# => {"foo"=>"http://example.org/foo", "bar"=>"http://example.org/bar"}
p a.attributes.name... -
REXML
:: Element # attribute(name , namespace = nil) -> REXML :: Attribute | nil (259.0) -
name で指定される属性を返します。
...
name で指定される属性を返します。
属性は REXML::Attribute オブジェクトの形で返します。
name は "foo:bar" のように prefix を指定することができます。
namespace で名前空間の URI を指定することで、その名前空間内で
name という......@param name 属性名(文字列)
@param namespace 名前空間のURI(文字列)
//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("/root/a").first
a.attribute("att") # => att='<'
a.attribute("att", "http://example.org/bar") # => bar:att='2'
a.attribute("bar:att") # => bar:att='2'
a.attribute("baz") # => nil
//}... -
REXML
:: Attributes # get _ attribute _ ns(namespace , name) -> REXML :: Attribute | nil (253.0) -
namespace と name で特定される属性を返します。
...namespace と name で特定される属性を返します。
namespace で名前空間を、 name で prefix を含まない属性名を
指定します。
指定された属性が存在しない場合は nil を返します。
XML プロセッサが prefix を置き換えてしまった場合......@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='<'/>
</root>
EOS
a =......doc.get_elements("/root/a").first
a.attributes.get_attribute_ns("", "att") # => att='<'
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/foo",... -
REXML
:: Attributes # [](name) -> String | nil (153.0) -
属性名nameの属性値を返します。
...属性名nameの属性値を返します。
属性値ではなく REXML::Attribute オブジェクトが必要な場合は
REXML::Attributes#get_attribute を使ってください。
nameという属性名の属性がない場合は nil を返します。
@param name 属性名(文字列)
//emlis......]{
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("/root/a").first
p a.attributes["att"] # => "<"
p a.attributes["bar:att"] # =>... -
REXML
:: Attributes # get _ attribute(name) -> Attribute | nil (153.0) -
name という名前の属性を取得します。
...name という名前の属性を取得します。
name という名前を持つ属性がない場合は nil を返します。
@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='<'/>
</root>
EOS
a = doc.get_elements("/root/a").first
a.attributes.get_attribute("att") # => att='<'
a.attributes.get_attribute("foo:att") # => foo:att='1'
//}... -
REXML
:: Attributes # each {|name , value| . . . } -> () (149.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='<'/>
</root>
EOS
a = doc.ge......t_elements("/root/a").first
a.attributes.each do |name, value|
p [name, value]
end
# => ["foo:att", "1"]
# => ["bar:att", "2"]
# => ["att", "<"]
//}... -
REXML
:: Attributes # delete _ all(name) -> [REXML :: Attribute] (147.0) -
name という名前を持つ属性をすべて削除します。
...
name という名前を持つ属性をすべて削除します。
削除された属性を配列で返します。
@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='<'/>
</root>
EOS
a = doc.get_elements("/root/a").first
a.attributes.delete_all("att") # => [att='<']
a # => <a foo:att='1' bar:att='2'/>
//}...