るりまサーチ

最速Rubyリファレンスマニュアル検索!
636件ヒット [1-100件を表示] (0.159秒)

別のキーワード

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

ライブラリ

キーワード

検索結果

<< 1 2 3 ... > >>

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

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

...][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_elements("/root/children/grandchi...
...ldren").first
grandchildren.name # => "grandchildren"
grandchildren.root.name # => "root"
//}...

REXML::Document#root -> REXML::Element | nil (26101.0)

文書のルート要素を返します。

文書のルート要素を返します。

文書がルート要素を持たない場合は nil を返します。

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

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

...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_node == doc # => true
grandchildren = doc.get_elements("/root/children/grand...
...children").first
grandchildren.name # => "grandchildren"
grandchildren.root_node == doc # => true
//}...

REXML::CData.new(text, respect_whitespace = true, parent = nil) -> REXML::CData (8060.0)

text をテキストとして持つ CData オブジェクトを生成します。

...{
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 ]]></root>\n"

doc = REXML::Document.new(<<EOS)
<root />
EOS
doc.root.add(REXML::CData.new("foo bar baz ", true))
doc.root.add(REXML:...
...:CData.new("foo bar baz ", false))
doc.to_s # => "<root><![CDATA[foo bar baz ]]><![CDATA[foo bar baz ]]></root>\n"
//}...

REXML::Elements#delete(element) -> Element (8054.0)

element で指定した子要素を取り除きます。

...by]{
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 # => "<a><c/><c id='1'/></a>"
doc.elements.delete("a/c[@id='1']") # => <c id='1'/>
doc.root.to_s...
...# => "<a><c/></a>"
doc.root.elements.delete 1 # => <c/>
doc.root.to_s # => "<a/>"
doc.root.elements.delete '/a'
doc.root.to_s # => ""
//}...

絞り込み条件を変える

REXML::Elements#[]=(index, element) (8048.0)

集合に要素 element を追加/更新します。

...'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/>
doc.root.elements[1] = REXML::Element.new('c')
doc.root.to_s # => "<a><c/></a>"
doc.root.elements['c'] = REXML::Element.new('d')
doc.root....

REXML::Formatters::Default (8048.0)

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

...require 'rexml/document'
require 'rexml/formatters/default'
doc = REXML::Document.new <<EOS
<root>
<children>
<grandchildren/>
</children>
</root>
EOS

default_formatter = REXML::Formatters::Default.new
output = StringIO.new
default_formatter.write(doc, output)
output.string
# => "<root>\n<childr...
...en>\n <grandchildren/>\n</children>\n</root>\n"

output = StringIO.new
default_formatter.write(REXML::XPath.first(doc, "/root/children"), output)
output.string
# => "<children>\n <grandchildren/>\n</children>"

ie_hack_formatter = REXML::Formatters::Default.new(true)
output = StringIO.new
ie_hack_...
...formatter.write(doc, output)
output.string
# => "<root>\n<children>\n <grandchildren />\n</children>\n</root>\n"
//}...

REXML::Formatters::Transitive (8048.0)

XMLドキュメントをテキストの内容を変えずに 多少の整形を加えて出力するクラスです。

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

transitive_formatter = REXML::Formatters::Transitive.new
output = StringIO.new
transitive_formatter.write(doc, output)
output.string
# => "<root...
...foo='bar'\n />\n</children\n ></root\n>\n"
print output.string
# >> <root
# >> ><children
# >> >
# >> <grandchildren foo='bar'
# >> />
# >> </children
# >> ></root
# >> >

output = StringIO.new
transitive_formatter.write(REXML::XPath.first(doc, "/root/children"), output)
output.string
#...

REXML::Element#add_attribute(attr) -> () (8042.0)

要素の属性を追加します。 同じ名前の属性がすでにある場合はその属性を新しい 属性で置き換えます。

...)

//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 # => <e a='b' x:a='c'/>
doc.root.add_attribute(REXML::Attribute.new("b", "d"))
doc.root # => <e a='b' x:a='c' b='d'/...
<< 1 2 3 ... > >>