Class: LibXML::XML::Namespace

### Home Classes Methods

### In Files

- lib/libxml/namespace.rb

### Parent

Object

### Methods

- #<=>
- #each
- #to_s

### Included Modules

- Comparable
- Enumerable

### Class/Module Index

Quicksearch

- LibXML
- LibXML::XML
- LibXML::XML::Attr
- LibXML::XML::AttrDecl
- LibXML::XML::Attributes
- LibXML::XML::Document
- LibXML::XML::Error
- LibXML::XML::HTMLParser
- LibXML::XML::Namespace
- LibXML::XML::Namespaces
- LibXML::XML::Node
- LibXML::XML::Parser
- LibXML::XML::Reader
- LibXML::XML::SaxParser
- LibXML::XML::SaxParser::Callbacks
- LibXML::XML::SaxParser::VerboseCallbacks
- LibXML::XML::Schema
- LibXML::XML::Schema::Attribute
- LibXML::XML::Schema::Element
- LibXML::XML::Schema::Namespaces
- LibXML::XML::Schema::Type
- LibXML::XML::Schema::Types
- LibXML::XML::XPath
- LibXML::XML::XPath::Object
- Object

No matching classes.

# LibXML::XML::Namespace

### Public Instance Methods

namespace1 <=> namespace2 click to toggle source

Compares two namespace objects. Namespace objects are considered equal if their prefixes and hrefs are the same.

    # File lib/libxml/namespace.rb, line 13
    def <=>(other)
      if self.prefix.nil? and other.prefix.nil?
        self.href <=> other.href
      elsif self.prefix.nil?
        -1
      elsif other.prefix.nil?
        1
      else
        self.prefix <=> other.prefix
      end
    end

each {|ns| .. } click to toggle source

libxml stores namespaces in memory as a linked list. Use the each method to iterate over the list. Note the first namespace in the loop is the current namespace.

Usage:

    namespace.each do |ns|
      ..
    end

    # File lib/libxml/namespace.rb, line 36
    def each
      ns = self

      while ns
        yield ns
        ns = ns.next
      end
    end

to_s → "string" click to toggle source

Returns the string represenation of a namespace.

Usage:

    namespace.to_s

    # File lib/libxml/namespace.rb, line 52
    def to_s
      if self.prefix
        "#{self.prefix}:#{self.href}"
      else
        self.href
      end
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.