| Module | HTree::Node |
| In: |
htree/display.rb
htree/extract_text.rb htree/loc.rb htree/modules.rb htree/raw_string.rb htree/rexml.rb |
HTree::Node#display_xml prints the node as XML.
The first optional argument, out, specifies output target. It should respond to <<. If it is not specified, $stdout is used.
The second optional argument, encoding, specifies output MIME charset (character encoding). If it is not specified, HTree::Encoder.internal_charset is used.
HTree::Node#display_xml returns out.
raw_string returns a source string recorded by parsing. It returns nil if the node is constructed not via parsing.
subst substitutes several subtrees at once.
t = HTree('<r><x/><y/><z/></r>')
l = t.make_loc
t2 = t.subst({
l.get_subnode(0, 'k') => 'v',
l.get_subnode(0, -1) => HTree('<a/>'),
l.get_subnode(0, 1) => nil,
l.get_subnode(0, 2, 0) => HTree('<b/>'),
})
pp t2
# =>
#<HTree::Doc
{elem <r k="v"> {emptyelem <a>} {emptyelem <x>} {elem <z> {emptyelem <b>}}}>