Sha256: 399d929c9c834cc0c8300f24a934e7456ee3e1d82cdca798cbac35f983fda7fa
Contents?: true
Size: 818 Bytes
Versions: 1
Compression:
Stored size: 818 Bytes
Contents
#! /usr/local/bin/ruby ## Visitor test ## 1998 by yoshidam ## require 'xml/dom/builder' require 'xml/dom/visitor' class Writer def visit_Document(document) document.children_accept(self) end def visit_Element(element) attrs = "" element.attributes.each do |attr| attrs += " " + attr.to_s end print "<#{element.nodeName}#{attrs}>" element.children_accept(self); print "</#{element.nodeName}>" end def visit_ProcessingInstruction(pi) print "<?" + pi.nodeValue + "?>" end def visit_Text(text) print text.nodeValue end def visit_Comment(comment) print "<!--" + comment.nodeValue + "-->" end def visit_CDATASection(cdata) print "<![CDATA[" + cdata.nodeValue + "]]>" end end doc = XML::DOM::Builder.new.parse($<.read) doc.accept(Writer.new)
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
mame-xmlparser-0.6.81.1 | samples/writer.rb |