るりまサーチ (Ruby 2.2.0)

最速Rubyリファレンスマニュアル検索!
5件ヒット [1-5件を表示] (0.044秒)
トップページ > クエリ:String[x] > バージョン:2.2.0[x] > ライブラリ:rexml[x] > クエリ:xpath[x]

別のキーワード

  1. string []=
  2. string []
  3. string slice
  4. string slice!
  5. string gsub

クラス

キーワード

検索結果

REXML::Element#xpath -> String (54694.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> .. <...

REXML::Attribute#xpath -> String (54658.0)

その属性を指定する xpath 文字列を返します。

その属性を指定する xpath 文字列を返します。

例えば "/foo/bar/@ns:r" という文字列を返します。

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

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

...ます。
REXML
::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 (76.0)

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

...列として)出力するクラスです。

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

//emlist[][ruby]{
require 'rexml/document'
require 'rexml/formatters/default'
doc = REXML::Document.new <<EOS
<root>
<children>
<grand...
...ren>
</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
# => "<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 (76.0)

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

...結果になるでしょう。

//emlist[][ruby]{
require '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
transit...
...>> <root
# >> ><children
# >> >
# >> <grandchildren foo='bar'
# >> />
# >> </children
# >> ></root
# >> >

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

絞り込み条件を変える