種類
- インスタンスメソッド (66)
- 特異メソッド (7)
- クラス (4)
- 定数 (3)
クラス
-
REXML
:: AttlistDecl (2) -
REXML
:: Attribute (6) -
REXML
:: Attributes (3) -
REXML
:: CData (2) -
REXML
:: Comment (7) -
REXML
:: Declaration (1) -
REXML
:: DocType (8) -
REXML
:: Document (6) -
REXML
:: Element (8) -
REXML
:: Entity (10) -
REXML
:: ExternalEntity (1) -
REXML
:: Instruction (2) -
REXML
:: NotationDecl (4) -
REXML
:: ParseException (1) -
REXML
:: Text (4) -
REXML
:: XMLDecl (5)
モジュール
-
REXML
:: Namespace (5) -
REXML
:: Node (1)
キーワード
- <=> (1)
- == (1)
- Comment (1)
-
DEFAULT
_ ENTITIES (1) -
DEFAULT
_ VERSION (1) - Default (1)
- Pretty (1)
- Transitive (1)
- UNDEFINED (1)
- [] (2)
-
add
_ element (1) -
attribute
_ of (1) - content (1)
-
element
_ name (1) - encoding (2)
- entities (1)
- entity (1)
- external (1)
-
external
_ id (1) -
local
_ name (1) - matches? (1)
- name (5)
- namespace (2)
- namespaces (2)
- ndata (1)
- new (4)
- normalize (1)
- normalized (1)
- prefix (2)
- prefixes (2)
- pubid (1)
- public (2)
- ref (1)
-
stand
_ alone? (2) - standalone (1)
- string= (1)
- system (2)
- target (1)
- text (1)
-
to
_ s (10) -
to
_ string (1) - unnormalize (1)
- unnormalized (1)
- value (4)
- version (2)
- xpath (2)
検索結果
先頭5件
-
REXML
:: Comment # string -> String (73222.0) -
コメント文字列を返します。
コメント文字列を返します。 -
REXML
:: Attribute # to _ string -> String (37252.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=(value) (36610.0) -
コメント文字列を設定します。
コメント文字列を設定します。
@param value 設定する文字列 -
REXML
:: Comment # to _ s -> String (18622.0) -
コメント文字列を返します。
コメント文字列を返します。 -
REXML
:: Text . unnormalize(string , doctype = nil , filter = nil , illegal = nil) -> String (1348.0) -
string を非正規化(すべての entity をアンエスケープ)したものを 返します。
...ype DTD(REXML::DocType オブジェクト)
@param filter アンエスケープしない実体の実体名(文字列配列)
@param illegal 内部用。使わないでください。
//emlist[][ruby]{
require 'rexml/text'
REXML::Text.unnormalize("& &foobar; <") # => "& &foobar; <"
REXML::Text.... -
REXML
:: Attributes # namespaces -> { String => String } (1216.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} (1216.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 (742.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 (646.0) -
Comment オブジェクトを生成します。
...mment オブジェクトを生成します。
引数に REXML::Comment オブジェクトを渡すとその内容が複製されます
(親ノードの情報は複製されません)。
@param string コメント文字列
@param comment REXML::Comment オブジェクト
@param parent 親ノード... -
REXML
:: CData # to _ s -> String (616.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 (616.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 (616.0) -
""(空文字列)を返します。
""(空文字列)を返します。
XMLの仕様上、このオブジェクトはexpanded name名前を持ちえません。 -
REXML
:: Document # name -> String (616.0) -
""(空文字列)を返します。
""(空文字列)を返します。
XMLの仕様上、このオブジェクトはexpanded name名前を持ちえません。 -
REXML
:: Namespace # local _ name -> String (616.0) -
prefix を含まない「ローカルな」名前を返します。
prefix を含まない「ローカルな」名前を返します。 -
REXML
:: Namespace # name -> String (616.0) -
prefix を含まない「ローカルな」名前を返します。
prefix を含まない「ローカルな」名前を返します。 -
REXML
:: XMLDecl # stand _ alone? -> String | nil (616.0) -
スタンドアロン文書であるかどうかを "yes" "no" で 返します。
スタンドアロン文書であるかどうかを "yes" "no" で
返します。
nil(省略)を返す場合もあります。 -
REXML
:: XMLDecl # standalone -> String | nil (616.0) -
スタンドアロン文書であるかどうかを "yes" "no" で 返します。
スタンドアロン文書であるかどうかを "yes" "no" で
返します。
nil(省略)を返す場合もあります。 -
REXML
:: ParseException # to _ s -> String (613.0) -
例外情報を文字列化して返します。
例外情報を文字列化して返します。 -
REXML
:: AttlistDecl # [](key) -> String | nil (610.0) -
key という属性名のデフォルト値を返します。
key という属性名のデフォルト値を返します。
key という名前の属性が存在しない、もしくは
デフォルト値を持たない場合は nil を返します。 -
REXML
:: AttlistDecl # element _ name -> String (610.0) -
属性を定義しているエレメントの名前を返します。
属性を定義しているエレメントの名前を返します。 -
REXML
:: Attribute # namespace(arg = nil) -> String | nil (610.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 (610.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 (610.0) -
正規化された属性値を返します。
正規化された属性値を返します。
属性値の正規化については XML の仕様を参考にしてください。 -
REXML
:: Attribute # value -> String (610.0) -
正規化されていない属性値を返します。
正規化されていない属性値を返します。
属性値の正規化については XML の仕様を参考にしてください。 -
REXML
:: Attribute # xpath -> String (610.0) -
その属性を指定する xpath 文字列を返します。
その属性を指定する xpath 文字列を返します。
例えば "/foo/bar/@ns:r" という文字列を返します。 -
REXML
:: Attributes # [](name) -> String | nil (610.0) -
属性名nameの属性値を返します。
...はなく REXML::Attribute オブジェクトが必要な場合は
REXML::Attributes#get_attribute を使ってください。
nameという属性名の属性がない場合は nil を返します。
@param name 属性名(文字列)
//emlist[][ruby]{
require 'rexml/document'
doc = REXML::Documen... -
REXML
:: Attributes # prefixes -> [String] (610.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 (610.0) -
ノードを文字列化します。
ノードを文字列化します。 -
REXML
:: DocType # attribute _ of(element , attribute) -> String | nil (610.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 } (610.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 (610.0) -
name という実体参照名を持つ実体を文字列で返します。
...れる文字列は非正規化(REXML::Entity#unnormalized 参照)
された文字列が返されます。
name という名前を持つ実体が存在しない場合には nil を返します。
@param name 実体参照名(文字列)
//emlist[][ruby]{
doctype = REXML::Document.new(<<EOS).doctype... -
REXML
:: DocType # external _ id -> String | nil (610.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 (610.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 (610.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 (610.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 } (610.0) -
XML の仕様上デフォルトで定義されている実体の Hash table。
...XML の仕様上デフォルトで定義されている実体の Hash table。
"amp" => REXML::EntityConst::AMP は含まれません。... -
REXML
:: Document # encoding -> String (610.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 (610.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 (610.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 (610.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] (610.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 (610.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 (610.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 (610.0) -
"UNDEFINED" という文字列。
"UNDEFINED" という文字列。 -
REXML
:: Entity # external -> String | nil (610.0) -
実体が外部実体(external entity)宣言である場合は "SYSTEM" もしくは "PUBLIC" という文字列を返します。
実体が外部実体(external entity)宣言である場合は
"SYSTEM" もしくは "PUBLIC" という文字列を返します。
内部実体(internal entity)宣言である場合には nil を返します。 -
REXML
:: Entity # name -> String (610.0) -
実体の名前を返します。
実体の名前を返します。 -
REXML
:: Entity # ndata -> String | nil (610.0) -
解析対象外実体(unparsed entity)宣言である場合には その記法名(notation name)を返します。
解析対象外実体(unparsed entity)宣言である場合には
その記法名(notation name)を返します。
それ以外の場合は nil を返します。 -
REXML
:: Entity # normalized -> String | nil (610.0) -
正規化された(normalized)実体の値を返します。
...正規化された(normalized)実体の値を返します。
すなわち、一切の実体参照を展開していない値を返します。
外部実体(external entity)宣言の場合は nil を返します。
@see REXML::Entity#value, REXML::Entity#unnormalized... -
REXML
:: Entity # pubid -> String | nil (610.0) -
公開識別子(public identifier)を用いた外部実体宣言の場合は、その公開識別子を 返します。
公開識別子(public identifier)を用いた外部実体宣言の場合は、その公開識別子を
返します。
それ以外の場合は nil を返します。 -
REXML
:: Entity # ref -> String | nil (610.0) -
外部実体(external entity)宣言の URI を返します。
外部実体(external entity)宣言の URI を返します。
内部実体宣言の場合は nil を返します。 -
REXML
:: Entity # to _ s -> String (610.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 (610.0) -
非正規化された(unnormalized)実体の値を返します。
...体の値を返します。
すなわち、self が属する DTD によってすべての実体参照(&ent; と %ent; の両方)
を展開した文字列を返します。
外部実体(external entity)宣言の場合は nil を返します。
@see REXML::Entity#value, REXML::Entity#normalized... -
REXML
:: Entity # value -> String | nil (610.0) -
実体の値を返します。
...ータ実体参照(parameter entity)のみが展開され、
そうでない実体参照(general entity)は展開されて
いないような値が返されます。
外部実体(external entity)宣言の場合は nil を返します。
@see REXML::Entity#unnormalized, REXML::Entity#normalized... -
REXML
:: ExternalEntity # to _ s -> String (610.0) -
宣言を文字列化します。
宣言を文字列化します。 -
REXML
:: Instruction # content -> String | nil (610.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 (610.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 (610.0) -
REXML::Namespace#name= で設定された名前を返します。
...REXML::Namespace#name= で設定された名前を返します。
name= で指定した名前が prefix を含んでいれば
prefix を含む名前を返し、そうでなければ
prefix を含まない名前を返します。
@see REXML::Namespace#prefix... -
REXML
:: Namespace # fully _ expanded _ name -> String (610.0) -
完全修飾名を返します。
完全修飾名を返します。 -
REXML
:: Namespace # prefix -> String (610.0) -
prefix (前置修飾子) を返します。
...prefix (前置修飾子) を返します。
@see REXML::Namespace#prefix=... -
REXML
:: Node # to _ s(indent = -1) -> String (610.0) -
ノードを文字列に変換します。
ノードを文字列に変換します。
@param indent このパラメータは deprecated で、無視されます -
REXML
:: NotationDecl # name -> String (610.0) -
記法宣言の名前を返します。
記法宣言の名前を返します。 -
REXML
:: NotationDecl # public -> String | nil (610.0) -
公開識別子を返します。
公開識別子を返します。
宣言が公開識別子を含まない場合は nil を返します。 -
REXML
:: NotationDecl # system -> String | nil (610.0) -
システム識別子(URI)を返します。
システム識別子(URI)を返します。
宣言がシステム識別子を含まない場合は nil を返します。 -
REXML
:: NotationDecl # to _ s -> String (610.0) -
self を文字列化したものを返します。
self を文字列化したものを返します。 -
REXML
:: Text # to _ s -> String (610.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 # => "< & foobar"... -
REXML
:: Text # value -> String (610.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 # => "< & foobar"
t.value # => "< & foobar"
//}... -
REXML
:: Text . normalize(input , doctype = nil , entity _ filter = nil) -> String (610.0) -
input を正規化(すべての entity をエスケープ)したものを 返します。
...input を正規化(すべての entity をエスケープ)したものを
返します。
@param input 正規化する文字列
@param doctype DTD(REXML::DocType オブジェクト)
@param entity_filter 置換したい実体の名前の配列... -
REXML
:: XMLDecl # encoding -> String | nil (610.0) -
設定されているエンコーディングの名前を文字列で返します。
設定されているエンコーディングの名前を文字列で返します。
エンコーディングが指定されていない(デフォルトの UTF-8 とみなされます)
場合は nil を返します。 -
REXML
:: XMLDecl # version -> String (610.0) -
XML文書のバージョンを文字列で返します。
XML文書のバージョンを文字列で返します。 -
REXML
:: XMLDecl :: DEFAULT _ VERSION -> String (610.0) -
REXML::XMLDecl.new や REXML::XMLDecl.default で の使われるデフォルトのXMLバージョン。
...REXML::XMLDecl.new や REXML::XMLDecl.default で
の使われるデフォルトのXMLバージョン。... -
REXML
:: Comment (112.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 (112.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 (112.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 (100.0) -
other と内容(REXML::Comment#string)を比較します。
...other と内容(REXML::Comment#string)を比較します。... -
REXML
:: Comment # ==(other) -> bool (100.0) -
other と内容(REXML::Comment#string)が同じならば真を返します。
...other と内容(REXML::Comment#string)が同じならば真を返します。... -
REXML
:: Element # add _ element(element , attrs = nil) -> Element (76.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 (46.0) -
Comment オブジェクトを生成します。
...mment オブジェクトを生成します。
引数に REXML::Comment オブジェクトを渡すとその内容が複製されます
(親ノードの情報は複製されません)。
@param string コメント文字列
@param comment REXML::Comment オブジェクト
@param parent 親ノード... -
REXML
:: Document . new(source = nil , context = {}) -> REXML :: Document (40.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 (40.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 (40.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よりも空...