Module: Hpricot

### Home Classes Methods

### In Files

- lib/hpricot/blankslate.rb
- lib/hpricot/builder.rb
- lib/hpricot/elements.rb
- lib/hpricot/htmlinfo.rb
- lib/hpricot/inspect.rb
- lib/hpricot/modules.rb
- lib/hpricot/parse.rb
- lib/hpricot/tag.rb
- lib/hpricot/tags.rb
- lib/hpricot/traverse.rb
- lib/hpricot/xchar.rb

### Namespace

- MODULE Hpricot::Builder
- MODULE Hpricot::Container
- MODULE Hpricot::Leaf
- MODULE Hpricot::Node
- MODULE Hpricot::Traverse
- CLASS Hpricot::Attributes
- CLASS Hpricot::BlankSlate
- CLASS Hpricot::BogusETag
- CLASS Hpricot::CData
- CLASS Hpricot::Comment
- CLASS Hpricot::Context
- CLASS Hpricot::CssProxy
- CLASS Hpricot::Doc
- CLASS Hpricot::DocType
- CLASS Hpricot::ETag
- CLASS Hpricot::Elem
- CLASS Hpricot::Elements
- CLASS Hpricot::EncodingError
- CLASS Hpricot::Error
- CLASS Hpricot::Name
- CLASS Hpricot::ProcIns
- CLASS Hpricot::Text
- CLASS Hpricot::XHTMLStrict
- CLASS Hpricot::XHTMLTransitional
- CLASS Hpricot::XMLDecl

### Methods

- ::XML
- ::build
- ::parse
- ::uxs
- ::xchr
- ::xs

### Files

- CHANGELOG
- COPYING

### Class/Module Index

Quicksearch

- Hpricot
- Hpricot::BlankSlate
- Hpricot::BogusETag::Trav
- Hpricot::Builder
- Hpricot::CData::Trav
- Hpricot::Comment::Trav
- Hpricot::Container
- Hpricot::Container::Trav
- Hpricot::Context
- Hpricot::CssProxy
- Hpricot::Doc::Trav
- Hpricot::DocType::Trav
- Hpricot::Elem::Trav
- Hpricot::EncodingError
- Hpricot::Error
- Hpricot::Leaf
- Hpricot::Leaf::Trav
- Hpricot::Name
- Hpricot::Node
- Hpricot::ProcIns::Trav
- Hpricot::Text::Trav
- Hpricot::Traverse
- Hpricot::XHTMLStrict
- Hpricot::XHTMLTransitional
- Hpricot::XMLDecl::Trav
- Kernel
- Object

No matching classes.

# Hpricot

    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.

++

### Constants

AttrCore

  Common sets of attributes.

AttrEvents
AttrFocus
AttrHAlign
AttrI18n
AttrVAlign
Attrs
FORM_TAGS
SELF_CLOSING_TAGS

### Public Class Methods

XML(input = nil, opts = {}, &blk) click to toggle source

Hpricot::XML parses input, disregarding all the HTML rules and returning a document tree.

    # File lib/hpricot/parse.rb, line 20
    def Hpricot.XML(input = nil, opts = {}, &blk)
      opts.merge! :xml => true
      make(input, opts, &blk)
    end

build(ele = Doc.new, assigns = {}, &blk) click to toggle source

    # File lib/hpricot/builder.rb, line 15
    def self.build(ele = Doc.new, assigns = {}, &blk)
      ele.extend Builder
      assigns.each do |k, v|
        ele.instance_variable_set("@#{k}", v)
      end
      ele.instance_eval(&blk)
      ele
    end

parse(input = nil, opts = {}, &blk) click to toggle source

Hpricot.parse parses input and return a document tree. represented by Hpricot::Doc.

    # File lib/hpricot/parse.rb, line 14
    def Hpricot.parse(input = nil, opts = {}, &blk)
      make(input, opts, &blk)
    end

uxs(str) click to toggle source

XML unescape

    # File lib/hpricot/builder.rb, line 8
    def self.uxs(str)
      str.to_s.
          gsub(/\&(\w+);/) { [NamedCharacters[$1] || 63].pack("U*") }. # 63 = ?? (query char)
          gsub(/\&\#(\d+);/) { [$1.to_i].pack("U*") }.
          gsub(/\&\#x([0-9a-fA-F]+);/) { [$1.to_i(16)].pack("U*") }
    end

xchr(str) click to toggle source

XML escaped version of chr

    # File lib/hpricot/xchar.rb, line 70
    def xchr(str)
      n = XChar::CP1252[str] || str
      case n when *XChar::VALID
        XChar::PREDEFINED[n] or (n<128 ? n.chr : "&##{n};")
      else
        '*'
      end
    end

xs(str) click to toggle source

XML escaped version of to_s

    # File lib/hpricot/xchar.rb, line 80
    def xs(str)
      str.to_s.unpack('U*').map {|n| xchr(n)}.join # ASCII, UTF-8
    rescue
      str.to_s.unpack('C*').map {|n| xchr(n)}.join # ISO-8859-1, WIN-1252
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.