るりまサーチ

最速Rubyリファレンスマニュアル検索!
48件ヒット [1-48件を表示] (0.133秒)
トップページ > クエリ:t[x] > クエリ:Ruby[x] > クエリ:string[x] > クエリ:xpath[x]

別のキーワード

  1. rbconfig ruby
  2. fiddle ruby_free
  3. fiddle build_ruby_platform
  4. rake ruby
  5. rubygems/defaults ruby_engine

ライブラリ

クラス

キーワード

検索結果

REXML::Element#xpath -> String (24336.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/><b/></a>')
b = doc.root.elements[2] # <a...
...> .. </a> の中の2番目の <b/> 要素
b # => <b/>
b.xpath # => "/a/b[2]"
//}...

REXML::Element#text(path = nil) -> String | nil (6219.0)

先頭のテキスト子ノードの文字列を返します。

...:Text#value も参照してください。

path を渡した場合は、その XPath 文字列で指定される
テキストノードの文字列を返します。

テキストノードがない場合には 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 text " と " more text"
# を持っているが、前者を返す
doc.root.text # => "some text "
//}...

REXML::Formatters::Default (6030.0)

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

...rmatters::Pretty と
異なりテキストの改行や空白を修正せずにそのまま出力します。

//emlist[][ruby]{
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<children>\n <grandchildren/>\n</children>\n</root>\n"

output = StringIO.new
default_formatter.write(REXML::XPath.first(doc, "/root/children"), output)
output.string
# => "<child...
...ren>\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 (6030.0)

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

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

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

output = StringIO.new
t
ransitive_formatter.write(REXML::XPath.f...
...irst(doc, "/root/children"), output)
output.string
# => "<children\n>\n<grandchildren foo='bar'\n />\n</children\n>"
//}...