別のキーワード
種類
- インスタンスメソッド (35)
- 特異メソッド (5)
- クラス (5)
クラス
-
REXML
:: Attributes (12) -
REXML
:: CData (3) -
REXML
:: Element (13) -
REXML
:: Elements (6) -
REXML
:: Instruction (2) -
REXML
:: Text (1) -
REXML
:: XPath (3)
キーワード
- Comment (1)
- Default (1)
- Instruction (1)
- Pretty (1)
- Transitive (1)
- [] (2)
- []= (2)
-
add
_ attribute (2) -
add
_ element (1) - attribute (1)
- content (1)
- delete (2)
-
delete
_ all (1) - each (3)
-
each
_ attribute (1) -
each
_ element _ with _ attribute (1) -
each
_ element _ with _ text (1) - first (1)
-
get
_ attribute (1) -
get
_ attribute _ ns (1) -
get
_ text (1) - length (1)
- match (1)
- namespaces (1)
- new (2)
-
next
_ element (1) - prefixes (1)
-
root
_ node (1) - size (2)
- target (1)
- text (1)
- text= (1)
-
to
_ a (1) -
to
_ s (1) - value (1)
- xpath (1)
検索結果
先頭5件
-
REXML
:: Element # root -> REXML :: Element (78526.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... -
REXML
:: Element # root _ node -> REXML :: Document | REXML :: Node (42490.0) -
self が属する文書のルートノードを返します。
...XML::Document オブジェクトが存在しない
場合は木構造上のルートノードが返されます。
//emlist[][ruby]{
require 'rexml/document'
doc = REXML::Document.new(<<EOS)
<root>
<children>
<grandchildren />
</children>
</root>
EOS
children = doc.get_elements("/root/children")... -
REXML
:: XPath . first(element , path = nil , namespaces = {} , variables = {}) -> Node | nil (24331.0) -
element の path で指定した XPath 文字列にマッチする最初のノードを 返します。
...文字列
@param 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... -
REXML
:: Formatters :: Default (24295.0) -
XMLドキュメントを(文字列として)出力するクラスです。
...ML::Formatters::Pretty と
異なりテキストの改行や空白を修正せずにそのまま出力します。
//emlist[][ruby]{
require 'rexml/document'
require 'rexml/formatters/default'
doc = REXML::Document.new <<EOS
<root>
<children>
<grandchildren/>
</children>
</root>
EOS
default_form... -
REXML
:: Formatters :: Transitive (24259.0) -
XMLドキュメントをテキストの内容を変えずに 多少の整形を加えて出力するクラスです。
...にたつかもしれません。
ただ、ほとんどの場合は奇妙な出力結果になるでしょう。
//emlist[][ruby]{
require 'rexml/document'
require 'rexml/formatters/transitive'
doc = REXML::Document.new <<EOS
<root><children>
<grandchildren foo='bar' />
</children></root>
EOS
tran... -
REXML
:: CData . new(text , respect _ whitespace = true , parent = nil) -> REXML :: CData (24223.0) -
text をテキストとして持つ CData オブジェクトを生成します。
...字列
@param respect_whitespace 空白を保存するかどうかを決める真偽値
@param parent 親ノード
//emlist[][ruby]{
require 'rexml/document'
doc = REXML::Document.new(<<EOS)
<root />
EOS
doc.root.add(REXML::CData.new("foo bar baz "))
doc.to_s # => "<root><![CDATA[foo bar baz ]]><... -
REXML
:: Element # each _ element _ with _ attribute(key , value = nil , max = 0 , name = nil) {|element| . . . } -> () (24223.0) -
特定の属性を持つすべての子要素を引数としてブロックを呼び出します。
...値(文字列)
@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.each_element_with_attribute('id'){|e| p e }
# >> <b id='1'/... -
REXML
:: Element # each _ element _ with _ text(text = nil , max = 0 , name = nil) {|element| . . . } -> () (24223.0) -
テキストを子ノードとして 持つすべての子要素を引数としてブロックを呼び出します。
...身(文字列)
@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> ... </>
# >... -
REXML
:: Elements # [](index , name = nil) -> REXML :: Element | nil (24223.0) -
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=... -
REXML
:: Elements # delete(element) -> Element (24223.0) -
element で指定した子要素を取り除きます。
...けることに注意してください。
@param element 削除する要素(REXML::Element, 整数, 文字列)
//emlist[][ruby]{
require 'rexml/document'
doc = REXML::Document.new '<a><b/><c/><c id="1"/></a>'
b = doc.root.elements[1]
doc.root.elements.delete b # => <b/>
doc.root.to_s... -
REXML
:: Elements # each(xpath = nil) {|element| . . . } -> [REXML :: Elements] (24223.0) -
全ての子要素に対しブロックを呼び出します。
...ストノードなどはすべて無視されることに注意してください。
@param xpath XPath文字列
//emlist[][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/> がブロックに渡... -
REXML
:: XPath . match(element , path = nil , namespaces = {} , variables = {}) -> [Node] (24223.0) -
element の path で指定した XPath 文字列にマッチするノードの配列を 返します。
...文字列
@param 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... -
REXML
:: XPath . each(element , path = nil , namespaces = {} , variables = {}) {|e| . . . } -> () (24205.0) -
element の path で指定した XPath 文字列にマッチする各ノード に対してブロックを呼び出します。
...文字列
@param 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... -
REXML
:: Element # add _ attribute(attr) -> () (24187.0) -
要素の属性を追加します。 同じ名前の属性がすでにある場合はその属性を新しい 属性で置き換えます。
...key 属性名(文字列)
@param value 属性値(文字列)
@param attr 属性(REXML::Attribute オブジェクト)
//emlist[][ruby]{
require 'rexml/document'
doc = REXML::Document.new("<e/>")
doc.root.add_attribute("a", "b"); doc.root # => <e a='b'/>
doc.root.add_attribute("x:a", "c"); doc.root # =... -
REXML
:: Element # add _ attribute(key , value) -> () (24187.0) -
要素の属性を追加します。 同じ名前の属性がすでにある場合はその属性を新しい 属性で置き換えます。
...key 属性名(文字列)
@param value 属性値(文字列)
@param attr 属性(REXML::Attribute オブジェクト)
//emlist[][ruby]{
require 'rexml/document'
doc = REXML::Document.new("<e/>")
doc.root.add_attribute("a", "b"); doc.root # => <e a='b'/>
doc.root.add_attribute("x:a", "c"); doc.root # =... -
REXML
:: Element # add _ element(element , attrs = nil) -> Element (24187.0) -
子要素を追加します。
...された要素です。
@param element 追加する要素
@param attrs 追加する要素に設定する属性
//emlist[][ruby]{
require 'rexml/document'
doc = REXML::Document.new('<a/>')
el = doc.root.add_element 'my-tag' # => <my-tag/>
doc.root.to_s # => "<a><my-tag/></a>"
el = doc.root.add_ele... -
REXML
:: Elements # to _ a(xpath = nil) -> [REXML :: Element] (24187.0) -
すべての子要素の配列を返します。
...XPath.match などと
異なり、要素以外の子ノードは無視されます。
@param xpath XPath文字列
//emlist[][ruby]{
require 'rexml/document'
require 'rexml/xpath'
doc = REXML::Document.new '<a>sean<b/>elliott<c/></a>'
doc.root.elements.to_a # => [<b/>, <c/>]
doc.root.elements.to_... -
REXML
:: Formatters :: Pretty (24187.0) -
XMLドキュメントを(文字列として)見た目良く出力するクラスです。
...Formatters::Default と
異なり見た目のためテキストの改行や空白を修正して出力します。
//emlist[][ruby]{
require 'rexml/document'
require 'rexml/formatters/pretty'
doc = REXML::Document.new <<EOS
<root>
<children>
<grandchildren foo='bar'/>
</children>
</root>
EOS
pre... -
REXML
:: Attributes # delete(attribute) -> REXML :: Element (24169.0) -
指定した属性を取り除きます。
...を返します。
@param attribute 取り除く属性(文字列もしくは REXML::Attribute オブジェクト)
//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:at... -
REXML
:: Element # xpath -> String (24169.0) -
文書上の対象の要素にのみマッチする xpath 文字列を返します。
...文書上の対象の要素にのみマッチする xpath 文字列を返します。
//emlist[][ruby]{
require 'rexml/document'
doc = REXML::Document.new('<a><b/><c/></a>')
c = doc.root.elements[2] # <a> .. </a> の中の <c/> 要素
c # => <c/>
c.xpath # => "/a/c"
doc = REXML::Document.new('<a><b... -
REXML
:: Elements # []=(index , element) (24169.0) -
集合に要素 element を追加/更新します。
...されます。
@param index 要素を更新する位置
@param element 要素(REXML::Elementオブジェクト)
//emlist[][ruby]{
require 'rexml/document'
doc = REXML::Document.new '<a/>'
doc.root.elements[10] = REXML::Element.new('b')
doc.root.to_s # => "<a><b/></a>"
doc.root.elements[1] # => <b... -
REXML
:: Attributes # []=(name , value) (24133.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=... -
REXML
:: Attributes # delete _ all(name) -> [REXML :: Attribute] (24133.0) -
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=... -
REXML
:: Attributes # namespaces -> { String => String } (24133.0) -
self の中で宣言されている名前空間の集合を返します。
...返します。
返り値は名前空間の prefix をキーとし、URI を値とする
Hash を返します。
//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=... -
REXML
:: Attributes # prefixes -> [String] (24133.0) -
self の中で宣言されている prefix の集合を 文字列の配列で返します。
...返します。
self が属する要素より上位の要素で定義されているものは含みません。
//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='... -
REXML
:: Element # text=(text) (24133.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... -
REXML
:: Elements # size -> Integer (24133.0) -
保持している要素の個数を返します。
...保持している要素の個数を返します。
//emlist[][ruby]{
require 'rexml/document'
doc = REXML::Document.new '<a>sean<b/>elliott<b/>russell<b/></a>'
# doc.root は3つの要素と3つのテキストノードを持つため、6を返す
doc.root.size # => 6
# そのうち要... -
REXML
:: Text . new(arg , respect _ whitespace = false , parent = nil , raw = nil , entity _ filter = nil , illegal = REXML :: Text :: NEEDS _ A _ SECOND _ CHECK) (24133.0) -
テキストノードオブジェクトを生成します。
...L::Text.new("<&", false, nil, true).to_s # parse error
//}
//emlist[doctype があり、実体が宣言されている場合][ruby]{
require 'rexml/document'
doc = REXML::Document.new(<<EOS)
doctype = REXML::Document.new(<<EOS).doctype
<!DOCTYPE root [
<!ENTITY p "foobar publisher">
<!ENTITY % q "q... -
REXML
:: Attributes # [](name) -> String | nil (24115.0) -
属性名nameの属性値を返します。
...い。
nameという属性名の属性がない場合は nil を返します。
@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... -
REXML
:: Attributes # each {|name , value| . . . } -> () (24115.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='... -
REXML
:: Attributes # each _ attribute {|attribute| . . . } -> () (24115.0) -
各属性に対しブロックを呼び出します。
...ブロックを呼び出します。
個々の属性は REXML::Attribute オブジェクトで渡されます。
//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=... -
REXML
:: Attributes # get _ attribute(name) -> Attribute | nil (24115.0) -
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:at... -
REXML
:: Attributes # get _ attribute _ ns(namespace , name) -> REXML :: Attribute | nil (24115.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... -
REXML
:: Attributes # length -> Integer (24115.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='<'/>
</root>
EOS
a = doc.get_elements("/root/a").first
p a.attribu... -
REXML
:: Attributes # size -> Integer (24115.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='<'/>
</root>
EOS
a = doc.get_elements("/root/a").first
p a.attribu... -
REXML
:: CData # to _ s -> String (24115.0) -
テキスト文字列を返します。
...テキスト文字列を返します。
@see REXML::Text#value, REXML::Text#to_s
//emlist[][ruby]{
require 'rexml/document'
doc = REXML::Document.new(<<EOS)
<root><![CDATA[foobar baz]]></root>
EOS
doc.root[0].class # => REXML::CData
doc.root[0].value # => "foobar baz"
//}... -
REXML
:: CData # value -> String (24115.0) -
テキスト文字列を返します。
...テキスト文字列を返します。
@see REXML::Text#value, REXML::Text#to_s
//emlist[][ruby]{
require 'rexml/document'
doc = REXML::Document.new(<<EOS)
<root><![CDATA[foobar baz]]></root>
EOS
doc.root[0].class # => REXML::CData
doc.root[0].value # => "foobar baz"
//}... -
REXML
:: Comment (24115.0) -
XML コメントを表すクラス。
...XML コメントを表すクラス。
コメントとは <!-- と --> で挟まれたテキストです。
//emlist[][ruby]{
require 'rexml/document'
doc = REXML::Document.new(<<EOS)
<!-- xx -->
<root>
<!-- yy -->
text
<!-- zz -->
</root>
EOS
doc[0].string # => " xx "
doc.root[1].string # => " yy... -
REXML
:: Element # attribute(name , namespace = nil) -> REXML :: Attribute | nil (24115.0) -
name で指定される属性を返します。
...場合は nil を返します。
@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=... -
REXML
:: Element # next _ element -> Element | nil (24097.0) -
次の兄弟要素を返します。
...次の兄弟要素を返します。
次の要素が存在しない場合は nil を返します。
//emlist[][ruby]{
require 'rexml/document'
doc = REXML::Document.new '<a><b/>text<c/></a>'
doc.root.elements['b'].next_element # => <c/>
doc.root.elements['c'].next_element # => nil
//}... -
REXML
:: Element # get _ text(path = nil) -> REXML :: Text | nil (24079.0) -
先頭のテキスト子ノードを返します。
...ストノードがない場合には nil を返します。
@param path XPath文字列
@see REXML::Element#text
//emlist[][ruby]{
require 'rexml/document'
doc = REXML::Document.new "<p>some text <b>this is bold!</b> more text</p>"
# doc.root (<p> ... </p>) は2つのテキストノード("some tex... -
REXML
:: Element # text(path = nil) -> String | nil (24079.0) -
先頭のテキスト子ノードの文字列を返します。
...トノードがない場合には nil を返します。
@param path XPath文字列
@see REXML::Element#get_text
//emlist[][ruby]{
require 'rexml/document'
doc = REXML::Document.new "<p>some text <b>this is bold!</b> more text</p>"
# doc.root (<p> ... </p>) は2つのテキストノード("some te... -
REXML
:: Instruction (24061.0) -
XML 処理命令(XML Processing Instruction, XML PI)を表すクラス。
...頭の <?xml version=... ?>)はXML処理命令ではありませんが、
似た見た目を持っています。
//emlist[][ruby]{
require 'rexml/document'
doc = REXML::Document.new(<<EOS)
<?xml version="1.0" encoding="utf-8" ?>
<?xml-stylesheet type="text/css" href="style.css"?>
<root />
EOS
doc[... -
REXML
:: Instruction # content -> String | nil (24061.0) -
XML 処理命令の内容を返します。
...XML 処理命令の内容を返します。
//emlist[][ruby]{
require 'rexml/document'
doc = REXML::Document.new(<<EOS)
<?xml version="1.0" encoding="utf-8" ?>
<?xml-stylesheet type="text/css" href="style.css"?>
<?foobar?>
<root />
EOS
doc[2] # => <?p-i xml-stylesheet ...?>
doc[2].target # => "xml-... -
REXML
:: Instruction # target -> String (24061.0) -
XML 処理命令のターゲットを返します。
...XML 処理命令のターゲットを返します。
//emlist[][ruby]{
require 'rexml/document'
doc = REXML::Document.new(<<EOS)
<?xml version="1.0" encoding="utf-8" ?>
<?xml-stylesheet type="text/css" href="style.css"?>
<root />
EOS
doc[2] # => <?p-i xml-stylesheet ...?>
doc[2].target # => "xml-st...