るりまサーチ (Ruby 2.3.0)

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

別のキーワード

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

検索結果

REXML::Attribute#to_string -> String (18628.0)

"name='value'" という形式の文字列を返します。

..."name='value'" という形式の文字列を返します。

//emlist[][ruby]{
require 'rexml/document'
e = REXML::Element.new("el")
e.add_attribute("ns:r", "rval")
p e.attributes.get_attribute("r").to_string # => "ns:r='rval'"
//}...

REXML::Comment#string -> String (18613.0)

コメント文字列を返します。

コメント文字列を返します。

REXML::Comment#string=(value) (18307.0)

コメント文字列を設定します。

コメント文字列を設定します。

@param value 設定する文字列

REXML::Comment#to_s -> String (9313.0)

コメント文字列を返します。

コメント文字列を返します。

REXML::Text.unnormalize(string, doctype = nil, filter = nil, illegal = nil) -> String (676.0)

string を非正規化(すべての entity をアンエスケープ)したものを 返します。

...ype DTD(REXML::DocType オブジェクト)
@param filter アンエスケープしない実体の実体名(文字列配列)
@param illegal 内部用。使わないでください。

//emlist[][ruby]{
require 'rexml/text'
REXML
::Text.unnormalize("&amp; &foobar; &lt;") # => "& &foobar; <"
REXML
::Text....

絞り込み条件を変える

REXML::Attributes#namespaces -> { String => String } (610.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='2' at...

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

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::Entity.matches?(string) -> bool (373.0)

string が実体宣言の文法に従う文字列であれば真を返します。

...あれば真を返します。

@param string 判定対象の文字列

//emlist[][ruby]{
require 'rexml/document'

p REXML::Entity.matches?('<!ENTITY s "seal">') # => true
p REXML::Entity.matches?('<!ENTITY % s "seal">') # => true
p REXML::Entity.matches?('<!ELEMENT br EMPTY >') # => false
//}...

REXML::Comment.new(string, parent = nil) -> REXML::Comment (325.0)

Comment オブジェクトを生成します。

...mment オブジェクトを生成します。

引数に REXML::Comment オブジェクトを渡すとその内容が複製されます
(親ノードの情報は複製されません)。

@param string コメント文字列
@param comment REXML::Comment オブジェクト
@param parent 親ノード...

REXML::CData#to_s -> String (310.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 (310.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::Document#expanded_name -> String (310.0)

""(空文字列)を返します。

""(空文字列)を返します。

XMLの仕様上、このオブジェクトはexpanded name名前を持ちえません。

REXML::Document#name -> String (310.0)

""(空文字列)を返します。

""(空文字列)を返します。

XMLの仕様上、このオブジェクトはexpanded name名前を持ちえません。

REXML::Namespace#local_name -> String (310.0)

prefix を含まない「ローカルな」名前を返します。

prefix を含まない「ローカルな」名前を返します。

REXML::Namespace#name -> String (310.0)

prefix を含まない「ローカルな」名前を返します。

prefix を含まない「ローカルな」名前を返します。

絞り込み条件を変える

REXML::ParseException#to_s -> String (310.0)

例外情報を文字列化して返します。

例外情報を文字列化して返します。

REXML::XMLDecl#stand_alone? -> String | nil (310.0)

スタンドアロン文書であるかどうかを "yes" "no" で 返します。

スタンドアロン文書であるかどうかを "yes" "no" で
返します。

nil(省略)を返す場合もあります。

REXML::XMLDecl#standalone -> String | nil (310.0)

スタンドアロン文書であるかどうかを "yes" "no" で 返します。

スタンドアロン文書であるかどうかを "yes" "no" で
返します。

nil(省略)を返す場合もあります。

REXML::AttlistDecl#[](key) -> String | nil (307.0)

key という属性名のデフォルト値を返します。

key という属性名のデフォルト値を返します。

key という名前の属性が存在しない、もしくは
デフォルト値を持たない場合は nil を返します。

REXML::AttlistDecl#element_name -> String (307.0)

属性を定義しているエレメントの名前を返します。

属性を定義しているエレメントの名前を返します。

絞り込み条件を変える

REXML::Attribute#namespace(arg = nil) -> String | nil (307.0)

属性の名前空間の URI を返します。

...でなく、arg という名前空間
の URI が返されます。
通常は省略します。

//emlist[][ruby]{
require 'rexml/document'
e = REXML::Element.new("el")
e.add_attribute("xmlns:ns", "http://www.example.com/ns")
e.add_attribute("ns:r", "rval")
p e.attributes.get_attribute...

REXML::Attribute#prefix -> String (307.0)

属性の名前空間を返します。

...//emlist[][ruby]{
require 'rexml/document'
e = REXML::Element.new( "elns:myelement" )
e.add_attribute( "nsa:a", "aval" )
e.add_attribute( "b", "bval" )
p e.attributes.get_attribute( "a" ).prefix # -> "nsa"
p e.attributes.get_attribute( "b" ).prefix # -> "elns"
a = REXML::Attribute.new( "x", "y"...

REXML::Attribute#to_s -> String (307.0)

正規化された属性値を返します。

正規化された属性値を返します。

属性値の正規化については XML の仕様を参考にしてください。

REXML::Attribute#value -> String (307.0)

正規化されていない属性値を返します。

正規化されていない属性値を返します。

属性値の正規化については XML の仕様を参考にしてください。

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

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

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

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

絞り込み条件を変える

REXML::Attributes#[](name) -> String | nil (307.0)

属性名nameの属性値を返します。

...はなく REXML::Attribute オブジェクトが必要な場合は
REXML
::Attributes#get_attribute を使ってください。

nameという属性名の属性がない場合は nil を返します。

@param name 属性名(文字列)

//emlist[][ruby]{
require 'rexml/document'

doc = REXML::Documen...

REXML::Attributes#prefixes -> [String] (307.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='2' att...

REXML::Declaration#to_s -> String (307.0)

ノードを文字列化します。

ノードを文字列化します。

REXML::DocType#attribute_of(element, attribute) -> String | nil (307.0)

DTD 内の属性リスト宣言で、 element という名前の要素の attribute という 名前の属性のデフォルト値を返します。

...合は nil を返します。

@param element 要素名(文字列)
@param attribute 属性名(文字列)

//emlist[][ruby]{
require 'rexml/document'

doctype = REXML::Document.new(<<EOS).doctype
<!DOCTYPE books [
<!ELEMENT book (comment)>
<!ELEMENT comment (#PCDATA)>
<!ATTLIST book
author...

REXML::DocType#entities -> { String => REXML::Entity } (307.0)

DTD で宣言されている実体の集合を Hash で返します。

...体参照名をキーとし、対応する REXML::Entity オブジェクト
を値とするハッシュテーブルです。

これには、XML のデフォルトの実体(gt, lt, quot, apos)も含まれています。

//emlist[][ruby]{
doctype = REXML::Document.new(<<EOS).doctype
<!DOCTYPE foo [...
...<!ENTITY bar "barbarbarbar">
]>
EOS

p doctype.entities # => { "gt" => #<REXML::Entity: ...>,
# "lt" => #<REXML::Entity: ...>, ... }
p doctype.entities["bar"].to_s # => "<!ENTITY bar \"barbarbarbar\">"
p doctype.entities["gt"].to_s # => "<!ENTITY gt \">\">"
//}...

絞り込み条件を変える

REXML::DocType#entity(name) -> String | nil (307.0)

name という実体参照名を持つ実体を文字列で返します。

...れる文字列は非正規化(REXML::Entity#unnormalized 参照)
された文字列が返されます。

name という名前を持つ実体が存在しない場合には nil を返します。

@param name 実体参照名(文字列)

//emlist[][ruby]{
doctype = REXML::Document.new(<<EOS).doctype...

REXML::DocType#external_id -> String | nil (307.0)

DTD が外部サブセットを用いている場合は "SYSTEM", "PUBLIC" の いずれかの文字列を返します。

...t[][ruby]{
require 'rexml/document'
doctype = REXML::Document.new(<<EOS).doctype
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
EOS
doctype.name # => "html"
doctype.external_id # => "PUBLIC"

doctype = REXML::Document.new(<<EO...

REXML::DocType#name -> String (307.0)

ルート要素名を返します。

...ルート要素名を返します。

//emlist[][ruby]{
document = REXML::Document.new(<<EOS)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
EOS
doctype = document.doctype
p doctype.name # => "html"
//}...

REXML::DocType#public -> String | nil (307.0)

DTD の公開識別子を返します。

...DTD が公開識別子による外部サブセットを含んでいない場合は nil を返します。

//emlist[][ruby]{
require 'rexml/document'
doctype = REXML::Document.new(<<EOS).doctype
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtm...
...l1-strict.dtd">
EOS
doctype.system # => "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
doctype.public # => "-//W3C//DTD XHTML 1.0 Strict//EN"

doctype = REXML::Document.new(<<EOS).doctype
<!DOCTYPE root SYSTEM "foobar">
EOS
doctype.system # => "foobar"
doctype.public # => nil
//}...

REXML::DocType#system -> String | nil (307.0)

DTD のシステム識別子を返します。

...子を返します。

DTD が外部サブセットを含んでいない場合は nil を返します。

//emlist[][ruby]{
require 'rexml/document'
doctype = REXML::Document.new(<<EOS).doctype
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1...
...-strict.dtd">
EOS
doctype.system # => "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
doctype.public # => "-//W3C//DTD XHTML 1.0 Strict//EN"

doctype = REXML::Document.new(<<EOS).doctype
<!DOCTYPE root SYSTEM "foobar">
EOS
doctype.system # => "foobar"
doctype.public # => nil
//}...

絞り込み条件を変える

REXML::DocType::DEFAULT_ENTITIES -> { String => REXML::Entity } (307.0)

XML の仕様上デフォルトで定義されている実体の Hash table。

...XML の仕様上デフォルトで定義されている実体の Hash table。

"amp" => REXML::EntityConst::AMP は含まれません。...

REXML::Document#encoding -> String (307.0)

XML 宣言に含まれている XML 文書のエンコーディングを返します。

...を返します。

文書が XML 宣言を持たない場合はデフォルトの値
(REXML::XMLDecl.defaultで宣言されているもの)を返します。

//emlist[][ruby]{
require 'rexml/document'
doc = REXML::Document.new(<<EOS)
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<e />
EO...

REXML::Document#stand_alone? -> String (307.0)

XML 宣言の standalone の値を文字列で返します。

...XML 宣言の standalone の値を文字列で返します。

//emlist[][ruby]{
require 'rexml/document'
doc = REXML::Document.new(<<EOS)
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<e />
EOS
doc.stand_alone? # => "yes"
//}...

REXML::Document#version -> String (307.0)

XML 宣言に含まれている XML 文書のバージョンを返します。

...を返します。

文書が XML 宣言を持たない場合はデフォルトの値
(REXML::XMLDecl.defaultで宣言されているもの)を返します。

//emlist[][ruby]{
require 'rexml/document'
doc = REXML::Document.new(<<EOS)
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<e />
EO...

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

self の文脈で 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"
b.namespace(...

絞り込み条件を変える

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

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#text(path = nil) -> String | nil (307.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::Element#xpath -> String (307.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::Element::UNDEFINED -> String (307.0)

"UNDEFINED" という文字列。

"UNDEFINED" という文字列。

REXML::Entity#external -> String | nil (307.0)

実体が外部実体(external entity)宣言である場合は "SYSTEM" もしくは "PUBLIC" という文字列を返します。

実体が外部実体(external entity)宣言である場合は
"SYSTEM" もしくは "PUBLIC" という文字列を返します。

内部実体(internal entity)宣言である場合には nil を返します。

絞り込み条件を変える

REXML::Entity#name -> String (307.0)

実体の名前を返します。

実体の名前を返します。

REXML::Entity#ndata -> String | nil (307.0)

解析対象外実体(unparsed entity)宣言である場合には その記法名(notation name)を返します。

解析対象外実体(unparsed entity)宣言である場合には
その記法名(notation name)を返します。

それ以外の場合は nil を返します。

REXML::Entity#normalized -> String | nil (307.0)

正規化された(normalized)実体の値を返します。

...正規化された(normalized)実体の値を返します。

すなわち、一切の実体参照を展開していない値を返します。

外部実体(external entity)宣言の場合は nil を返します。

@see REXML::Entity#value, REXML::Entity#unnormalized...

REXML::Entity#pubid -> String | nil (307.0)

公開識別子(public identifier)を用いた外部実体宣言の場合は、その公開識別子を 返します。

公開識別子(public identifier)を用いた外部実体宣言の場合は、その公開識別子を
返します。

それ以外の場合は nil を返します。

REXML::Entity#ref -> String | nil (307.0)

外部実体(external entity)宣言の URI を返します。

外部実体(external entity)宣言の URI を返します。

内部実体宣言の場合は nil を返します。

絞り込み条件を変える

REXML::Entity#to_s -> String (307.0)

実体宣言を文字列化したものを返します。

...実体宣言を文字列化したものを返します。

@see REXML::Entity#write

//emlist[][ruby]{
e = REXML::ENTITY.new("w", "wee");
p e.to_s # => "<!ENTITY w \"wee\">"
//}...

REXML::Entity#unnormalized -> String | nil (307.0)

非正規化された(unnormalized)実体の値を返します。

...体の値を返します。

すなわち、self が属する DTD によってすべての実体参照(&ent; と %ent; の両方)
を展開した文字列を返します。

外部実体(external entity)宣言の場合は nil を返します。

@see REXML::Entity#value, REXML::Entity#normalized...

REXML::Entity#value -> String | nil (307.0)

実体の値を返します。

...ータ実体参照(parameter entity)のみが展開され、
そうでない実体参照(general entity)は展開されて
いないような値が返されます。

外部実体(external entity)宣言の場合は nil を返します。

@see REXML::Entity#unnormalized, REXML::Entity#normalized...

REXML::ExternalEntity#to_s -> String (307.0)

宣言を文字列化します。

宣言を文字列化します。

REXML::Instruction#content -> String | nil (307.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 (307.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...

REXML::Namespace#expanded_name -> String (307.0)

REXML::Namespace#name= で設定された名前を返します。

...REXML::Namespace#name= で設定された名前を返します。

name= で指定した名前が prefix を含んでいれば
prefix を含む名前を返し、そうでなければ
prefix を含まない名前を返します。

@see REXML::Namespace#prefix...

REXML::Namespace#fully_expanded_name -> String (307.0)

完全修飾名を返します。

完全修飾名を返します。

REXML::Namespace#prefix -> String (307.0)

prefix (前置修飾子) を返します。

...prefix (前置修飾子) を返します。

@see REXML::Namespace#prefix=...

REXML::Node#to_s(indent = -1) -> String (307.0)

ノードを文字列に変換します。

ノードを文字列に変換します。

@param indent このパラメータは deprecated で、無視されます

絞り込み条件を変える

REXML::NotationDecl#name -> String (307.0)

記法宣言の名前を返します。

記法宣言の名前を返します。

REXML::NotationDecl#public -> String | nil (307.0)

公開識別子を返します。

公開識別子を返します。

宣言が公開識別子を含まない場合は nil を返します。

REXML::NotationDecl#system -> String | nil (307.0)

システム識別子(URI)を返します。

システム識別子(URI)を返します。

宣言がシステム識別子を含まない場合は nil を返します。

REXML::NotationDecl#to_s -> String (307.0)

self を文字列化したものを返します。

self を文字列化したものを返します。

REXML::Text#to_s -> String (307.0)

テキストの内容を正規化(すべての実体をエスケープ)された状態で返します。

...まり返り値は XML のテキストとして妥当です。

結果は REXML::Text.new で指定した entity_filter を反映しています。

@see REXML::Text#value

//emlist[][ruby]{
require 'rexml/document'
t = REXML::Text.new("< & foobar", false, nil, false)
t.to_s # => "&lt; &amp; foobar"...

絞り込み条件を変える

REXML::Text#value -> String (307.0)

テキストの内容を非正規化(すべての実体をアンエスケープ)された状態で返します。

...す。

このメソッドの返り値では raw モードや entity_filter は無視されます。

@see REXML::Text#raw, REXML::Text#to_s

//emlist[][ruby]{
require 'rexml/document'
t = REXML::Text.new("< & foobar", false, nil, false)
t.to_s # => "&lt; &amp; foobar"
t.value # => "< & foobar"
//}...

REXML::Text.normalize(input, doctype = nil, entity_filter = nil) -> String (307.0)

input を正規化(すべての entity をエスケープ)したものを 返します。

...input を正規化(すべての entity をエスケープ)したものを
返します。

@param input 正規化する文字列
@param doctype DTD(REXML::DocType オブジェクト)
@param entity_filter 置換したい実体の名前の配列...

REXML::XMLDecl#encoding -> String | nil (307.0)

設定されているエンコーディングの名前を文字列で返します。

設定されているエンコーディングの名前を文字列で返します。

エンコーディングが指定されていない(デフォルトの UTF-8 とみなされます)
場合は nil を返します。

REXML::XMLDecl#version -> String (307.0)

XML文書のバージョンを文字列で返します。

XML文書のバージョンを文字列で返します。

REXML::XMLDecl::DEFAULT_VERSION -> String (307.0)

REXML::XMLDecl.new や REXML::XMLDecl.default で の使われるデフォルトのXMLバージョン。

...REXML::XMLDecl.new や REXML::XMLDecl.default で
の使われるデフォルトのXMLバージョン。...

絞り込み条件を変える

REXML::Comment (58.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::Formatters::Default (58.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 (58.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>"
//}...

REXML::Comment#<=>(other) -> -1 | 0 | 1 (52.0)

other と内容(REXML::Comment#string)を比較します。

...other と内容(REXML::Comment#string)を比較します。...

REXML::Comment#==(other) -> bool (52.0)

other と内容(REXML::Comment#string)が同じならば真を返します。

...other と内容(REXML::Comment#string)が同じならば真を返します。...

絞り込み条件を変える

REXML::Element#add_element(element, attrs = nil) -> Element (40.0)

子要素を追加します。

...子要素を追加します。

element として追加する要素を指定します。
REXML
::Element オブジェクトもしくは文字列を指定します。

element として REXML::Element オブジェクトを指定した場合、それが追加されます。
文字列を指定した場...
...た要素です。

@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_element '...
...'val1' attr2='val2'/>
doc.root.to_s # => "<a><my-tag/><my-tag attr1='val1' attr2='val2'/></a>"
el = REXML::Element.new 'my-tag'
doc.root.add_element el # => <my-tag/>
doc.root.to_s # => "<a><my-tag/><my-tag attr1='val1' attr2='val2'/><my-tag/></a>"
//}

@see REXML::Elements#add, REXML::Element.new...

REXML::Comment.new(comment, parent = nil) -> REXML::Comment (25.0)

Comment オブジェクトを生成します。

...mment オブジェクトを生成します。

引数に REXML::Comment オブジェクトを渡すとその内容が複製されます
(親ノードの情報は複製されません)。

@param string コメント文字列
@param comment REXML::Comment オブジェクト
@param parent 親ノード...

REXML::Document.new(source = nil, context = {}) -> REXML::Document (22.0)

Document オブジェクトを生成します。

...Document オブジェクトを生成します。

source には String、IO、REXML::Document のいずかが
指定できます。 REXML::Document を指定すると
コンテキストと要素、属性が複製されます。
文字列の場合はそれを XML と見なしてパースします。...
...
また、すべての要素で空白を考慮して欲しい場合には
:all を指定します。
デフォルト値は :all です。
REXML
::Element#whitespace も参照してください。
: :compress_whitespace
空白を無視して欲しい要素の名前の集合を文字列の...
...ect_whitespace での指定を上書きします。
すべての要素で空白を無視して欲しい場合には
:all を指定します。
REXML
::Element#whitespace も参照してください。
: :ignore_whitespace_nodes
空白のみからなるノードを無視して欲しい要素...

REXML::Element.new(arg = UNDEFINED, parent = nil, context = nil) -> REXML::Element (22.0)

要素オブジェクトを生成します。

... REXML::Element オブジェクトの場合は、
新たな要素の名前、属性、context が arg のもので初期化されます。

parent で親ノードを指定します。

context には hash table で要素のコンテキストを指定します。
基本的には text node (REXML::...
...
また、すべての要素で空白を考慮して欲しい場合には
:all を指定します。
デフォルト値は :all です。
REXML
::Element#whitespace も参照してください。
: :compress_whitespace
空白を無視して欲しい要素の名前の集合を文字列の...
...ect_whitespace での指定を上書きします。
すべての要素で空白を無視して欲しい場合には
:all を指定します。
REXML
::Element#whitespace も参照してください。
: :ignore_whitespace_nodes
空白のみからなるノードを無視して欲しい要素...

REXML::Formatters::Pretty (22.0)

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

...た目良く出力するクラスです。

REXML
::Formatters::Default と
異なり見た目のためテキストの改行や空白を修正して出力します。

//emlist[][ruby]{
require 'rexml/document'
require 'rexml/formatters/pretty'
doc = REXML::Document.new <<EOS
<root>
<children>
<gra...
...ndchildren foo='bar'/>
</children>
</root>
EOS

pretty_formatter = REXML::Formatters::Pretty.new
output = StringIO.new
pretty_formatter.write(doc, output)
output.string
# => "<root>\n <children>\n <grandchildren foo='bar'/>\n </children>\n</root>"
# この出力結果は入力のXMLよりも空...

絞り込み条件を変える