るりまサーチ (Ruby 2.4.0)

最速Rubyリファレンスマニュアル検索!
13件ヒット [1-13件を表示] (0.013秒)
トップページ > クエリ:self[x] > バージョン:2.4.0[x] > クラス:REXML::Element[x]

別のキーワード

  1. object yield_self
  2. _builtin yield_self
  3. _builtin self
  4. tracepoint self
  5. codeobject document_self

ライブラリ

キーワード

検索結果

REXML::Element#add_namespace(prefix, uri) -> self (307.0)

名前空間を要素に追加します。

...上書きされます。

@param prefix 名前空間の prefix
@param uri 名前空間の uri

//emlist[][ruby]{
require 'rexml/document'
a = REXML::Element.new("a")
a.add_namespace("xmlns:foo", "bar" )
a.add_namespace("foo", "bar") # 上と同じ意味
a.add_namespace("twiddle")
a.to_s # => "<a xm...

REXML::Element#delete_namespace(namespace = "xmlns") -> self (307.0)

名前空間を要素から削除します。

名前空間を要素から削除します。

削除可能な名前空間はそのノードで宣言されているもののみです。
上位の要素で宣言されているものは削除できません。

引数を省略した場合はデフォルトの名前空間を削除します。

@param namespace 削除する名前空間の prefix

//emlist[][ruby]{
require 'rexml/document'
doc = REXML::Document.new "<a xmlns:foo='bar' xmlns='twiddle'/>"
doc.root.delete_namespace
doc.to_s # => "<a xmlns:foo=...

REXML::Element#whitespace -> bool (88.0)

要素(self)内で空白が考慮されるならば真を返します。

...要素(self)内で空白が考慮されるならば真を返します。

これは、
* REXML::Element#context に :respect_whitespace も :compress_whitespace も
含まれない
* context の :respect_whitespace に self の要素名が含まれていて、
:compress_whitespace に se...

REXML::Element#clone -> REXML::Element (52.0)

self を複製して返します。

self を複製して返します。

複製されるのは名前、属性、名前空間のみです。
子ノードは複製されません。

REXML::Element#document -> REXML::Document | nil (52.0)

self が属する文書(REXML::Document)オブジェクトを返します。

self が属する文書(REXML::Document)オブジェクトを返します。

属する文書がない場合には nil を返します。

絞り込み条件を変える

REXML::Element#has_elements? -> bool (52.0)

self が一つでも子要素を持つならば true を返します。

self が一つでも子要素を持つならば true を返します。

//emlist[][ruby]{
require 'rexml/document'
doc = REXML::Document.new("<a><b/><c>Text</c></a>")
doc.root.has_elements? # => true
doc.elements["/a/b"].has_elements? # => false
# /a/c はテキストノードしか持たないので false である
doc.elements["/a/c"].has_elements? # => f...

REXML::Element#namespace(prefix=nil) -> String (52.0)

self の文脈で prefix が指している名前空間の URI を返します。

self の文脈で prefix が指している名前空間の URI を返します。

prefix を省略すると、デフォルトの名前空間の URI を返します。

prefix で指示される名前空間の宣言が存在しない場合は nil を返します。

//emlist[][ruby]{
require 'rexml/document'
doc = REXML::Document.new("<a xmlns='1' xmlns:y='2'><b/><c xmlns:z='3'/><y:d /></a>")
b = doc.elements['//b']
b.namespace # => "1"
...

REXML::Element#namespaces -> {String => String} (52.0)

self の文脈で定義されている名前空間の情報を返します。

self の文脈で定義されている名前空間の情報を返します。

対象の要素とその外側の要素で定義されている名前空間を、{ prefix => 識別子 }
というハッシュテーブルで返します。

//emlist[][ruby]{
require 'rexml/document'
doc = REXML::Document.new("<a xmlns:x='1' xmlns:y='2'><b/><c xmlns:z='3'/></a>")
doc.elements['//b'].namespaces # => {"x"=>"1", "y"=>"2"}
//}

REXML::Element#prefixes -> [String] (52.0)

self の文脈で定義されている prefix を文字列の配列を返します。

self の文脈で定義されている prefix を文字列の配列を返します。

対象の要素とその外側の要素で定義されている prefix を返します。

//emlist[][ruby]{
require 'rexml/document'
doc = REXML::Document.new("<a xmlns:x='1' xmlns:y='2'><b/><c xmlns:z='3'/></a>")
doc.elements['//b'].prefixes # => ["x", "y"]
//}

REXML::Element#root -> REXML::Element (52.0)

self が属する文書のルート要素を返します。

self が属する文書のルート要素を返します。

//emlist[][ruby]{
require 'rexml/document'
doc = REXML::Document.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...

絞り込み条件を変える

REXML::Element#root_node -> REXML::Document | REXML::Node (52.0)

self が属する文書のルートノードを返します。

self が属する文書のルートノードを返します。

通常はその要素が属する文書(REXML::Document) オブジェクトが
返されます。

その要素が属する REXML::Document オブジェクトが存在しない
場合は木構造上のルートノードが返されます。

//emlist[][ruby]{
require 'rexml/document'
doc = REXML::Document.new(<<EOS)
<root>
<children>
<grandchildren />
</children>
</root>
EOS

children = doc.get_elements...

REXML::Element#raw -> bool (22.0)

その要素が raw モードであるならば真を返します。

...その要素が raw モードであるならば真を返します。

以下のいずれかであれば、raw モードであると判定されます。
* REXML::Element#context の :raw が :all である
* context の :raw の配列に self の要素名が含まれる...

REXML::Element#add_namespace(uri) (7.0)

名前空間を要素に追加します。

...上書きされます。

@param prefix 名前空間の prefix
@param uri 名前空間の uri

//emlist[][ruby]{
require 'rexml/document'
a = REXML::Element.new("a")
a.add_namespace("xmlns:foo", "bar" )
a.add_namespace("foo", "bar") # 上と同じ意味
a.add_namespace("twiddle")
a.to_s # => "<a xm...