66件ヒット
[1-66件を表示]
(0.074秒)
検索結果
先頭5件
-
REXML
:: Elements # delete(element) -> Element (50.0) -
element で指定した子要素を取り除きます。
...c.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.t......o_s # => "<a/>"
doc.root.elements.delete '/a'
doc.root.to_s # => ""
//}... -
REXML
:: Elements # []=(index , element) (44.0) -
集合に要素 element を追加/更新します。
...ML::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.to_s # => "<a><d/></a>"
//... -
REXML
:: Elements # [](index , name = nil) -> REXML :: Element | nil (38.0) -
index が指し示している要素を返します。
.../><d/></a>'
doc.root.elements[1] # => <b/>
doc.root.elements['c'] # => <c id='1'/>
doc.root.elements[2,'c'] # => <c id='2'/>
doc = REXML::Document.new '<a><b><c /><a id="1"/></b></a>'
doc.root.elements["a"] # => nil
doc.root.elements["b/a"] # => <a id='1'/>
doc.root.elements["/a"]... -
REXML
:: Elements # each(xpath = nil) {|element| . . . } -> [REXML :: Elements] (26.0) -
全ての子要素に対しブロックを呼び出します。
...,<c/>, <d/> がブロックに渡される
doc.root.elements.each {|e|p e}
# <b/>, <b/> がブロックに渡される
doc.root.elements.each('b') {|e|p e} #-> Yields b, b elements
# <b/>,<c/>,<d/>,<b/>,<c/>,<d/> がブロックに渡される
doc.root.elements.each('child::node()') {|e|p e}
# <b/......>,<c/>,<d/>,"sean",<b/>,<c/>,<d/> がブロックに渡される
REXML::XPath.each(doc.root, 'child::node()'){|node| p node }
//}... -
REXML
:: Elements # size -> Integer (20.0) -
保持している要素の個数を返します。
...ml/document'
doc = REXML::Document.new '<a>sean<b/>elliott<b/>russell<b/></a>'
# doc.root は3つの要素と3つのテキストノードを持つため、6を返す
doc.root.size # => 6
# そのうち要素は3つであるため、以下は3を返す
doc.root.elements.size # => 3
//}... -
REXML
:: Elements # to _ a(xpath = nil) -> [REXML :: Element] (20.0) -
すべての子要素の配列を返します。
...す。
REXML::Elements#each と同様、REXML::XPath.match などと
異なり、要素以外の子ノードは無視されます。
@param xpath XPath文字列
//emlist[][ruby]{
require 'rexml/document'
require 'rexml/xpath'
doc = REXML::Document.new '<a>sean<b/>elliott<c/></a>'
doc.root.element......s.to_a # => [<b/>, <c/>]
doc.root.elements.to_a("child::node()") # => [<b/>, <c/>]
REXML::XPath.match(doc.root, "child::node()") # => ["sean", <b/>, "elliott", <c/>]
//}...