Permission is granted for use, copying, modification, distribution, and distribution of modified versions of this work as long as the above copyright notice is included.
++
Common sets of attributes.
Hpricot::XML parses input, disregarding all the HTML rules and returning a document tree.
# File lib/hpricot/parse.rb, line 20 20: def Hpricot.XML(input = nil, opts = {}, &blk) 21: opts.merge! :xml => true 22: make(input, opts, &blk) 23: end
# File lib/hpricot/builder.rb, line 14 14: def self.build(ele = Doc.new, assigns = {}, &blk) 15: ele.extend Builder 16: assigns.each do |k, v| 17: ele.instance_variable_set("@#{k}", v) 18: end 19: ele.instance_eval(&blk) 20: ele 21: end
Hpricot.parse parses input and return a document tree. represented by Hpricot::Doc.
# File lib/hpricot/parse.rb, line 14 14: def Hpricot.parse(input = nil, opts = {}, &blk) 15: make(input, opts, &blk) 16: end
XML unescape
# File lib/hpricot/builder.rb, line 8 8: def self.uxs(str) 9: str.to_s. 10: gsub(/\&(\w+);/) { [NamedCharacters[$1] || ??].pack("U*") }. 11: gsub(/\&\#(\d+);/) { [$1.to_i].pack("U*") } 12: end
XML unescape
# File lib/hpricot/xchar.rb, line 87 87: def uxs(str) 88: str.to_s. 89: gsub(/\&\w+;/) { |x| (XChar::PREDEFINED_U[x] || ??).chr }. 90: gsub(/\&\#(\d+);/) { [$1.to_i].pack("U*") } 91: end
XML escaped version of chr
# File lib/hpricot/xchar.rb, line 70 70: def xchr(str) 71: n = XChar::CP1252[str] || str 72: case n when *XChar::VALID 73: XChar::PREDEFINED[n] or (n<128 ? n.chr : "&##{n};") 74: else 75: '*' 76: end 77: end
XML escaped version of to_s
# File lib/hpricot/xchar.rb, line 80 80: def xs(str) 81: str.to_s.unpack('U*').map {|n| xchr(n)}.join # ASCII, UTF-8 82: rescue 83: str.to_s.unpack('C*').map {|n| xchr(n)}.join # ISO-8859-1, WIN-1252 84: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.