Class: LibXML::XML::Namespaces

### Home Classes Methods

### In Files

- lib/libxml/namespaces.rb

### Parent

Object

### Methods

- #default
- #default_prefix=

### 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::Namespaces

### Public Instance Methods

default → XML::Namespace click to toggle source

Returns the default namespace for this node or nil.

Usage:

    doc = XML::Document.string('<Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/"/>')
    ns = doc.root.namespaces.default_namespace
    assert_equal(ns.href, 'http://schemas.xmlsoap.org/soap/envelope/')

    # File lib/libxml/namespaces.rb, line 14
    def default
      find_by_prefix(nil)
    end

default_prefix = "string" click to toggle source

Assigns a name (prefix) to the default namespace. This makes it much easier to perform XML::XPath searches.

Usage:

    doc = XML::Document.string('<Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/"/>')
    doc.root.namespaces.default_prefix = 'soap'
    node = doc.root.find_first('soap:Envelope')

    # File lib/libxml/namespaces.rb, line 29
    def default_prefix=(prefix)
      # Find default prefix

      ns = find_by_prefix(nil)
      raise(ArgumentError, "No default namespace was found") unless ns
      Namespace.new(self.node, prefix, ns.href)
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.