Sha256: 91fff55a69b186770f598cbab25a115a2db59a152c7e7daa05224cc7fc7b41d5
Contents?: true
Size: 1002 Bytes
Versions: 2
Compression:
Stored size: 1002 Bytes
Contents
require "xml/libxml" class XML::Node ## # Open up XML::Node from libxml and add convenience methods inspired # by hpricot. # (http://code.whytheluckystiff.net/hpricot/wiki/HpricotBasics) # find the child node with the given xpath def at(xpath) self.find_first(xpath) end # find the array of child nodes matching the given xpath def search(xpath) results = self.find(xpath).to_a if block_given? results.each do |result| yield result end end return results end # alias for search def /(xpath) search(xpath) end # return the inner contents of this node as a string def inner_xml child.to_s end # alias for inner_xml def inner_html inner_xml end # return this node and its contents as an xml string def to_xml self.to_s end # alias for path def xpath self.path end end class String def to_libxml_doc xp = XML::Parser.new xp.string = self return xp.parse end end
Version data entries
2 entries across 2 versions & 2 rubygems
Version | Path |
---|---|
jnunemaker-happymapper-0.2.0 | lib/libxml_ext/libxml_helper.rb |
happymapper-0.2.0 | lib/libxml_ext/libxml_helper.rb |