Class LibXML::XML::Namespaces
In: lib/libxml/namespaces.rb
Parent: Object

Methods

Public Instance methods

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/')

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')

[Validate]