Class: Handsoap::XmlQueryFront::LibXMLDriver

Inherits:
Object
  • Object
show all
Includes:
XmlElement
Defined in:
lib/handsoap/xml_query_front.rb

Overview

Driver for libxml.

libxml.rubyforge.org/

Instance Method Summary collapse

Methods included from XmlElement

#/, #add_namespace, #assert_prefixes!, #initialize, #native_element, #to_boolean, #to_date, #to_f, #to_i

Instance Method Details

#[](attribute_name) ⇒ Object

Raises:

  • (ArgumentError)


243
244
245
246
# File 'lib/handsoap/xml_query_front.rb', line 243

def [](attribute_name)
  raise ArgumentError.new unless attribute_name.kind_of? String
  @element[attribute_name]
end

#childrenObject



240
241
242
# File 'lib/handsoap/xml_query_front.rb', line 240

def children
  NodeSelection.new(@element.children.map{|node| LibXMLDriver.new(node) })
end

#node_nameObject



224
225
226
# File 'lib/handsoap/xml_query_front.rb', line 224

def node_name
  @element.name
end

#node_namespaceObject



227
228
229
230
231
232
233
# File 'lib/handsoap/xml_query_front.rb', line 227

def node_namespace
  if @element.respond_to? :namespaces
    if namespace = @element.namespaces.namespace
      namespace.href
    end
  end
end

#to_rawObject



250
251
252
# File 'lib/handsoap/xml_query_front.rb', line 250

def to_raw
  @element.to_s(:indent => false)
end

#to_sObject



253
254
255
256
257
258
259
# File 'lib/handsoap/xml_query_front.rb', line 253

def to_s
  if @element.kind_of? LibXML::XML::Attr
    @element.value
  else
    @element.content
  end
end

#to_xmlObject



247
248
249
# File 'lib/handsoap/xml_query_front.rb', line 247

def to_xml
  @element.to_s(:indent => true)
end

#xpath(expression, ns = nil) ⇒ Object



234
235
236
237
238
239
# File 'lib/handsoap/xml_query_front.rb', line 234

def xpath(expression, ns = nil)
  ns = {} if ns.nil?
  ns = @namespaces.merge(ns)
  assert_prefixes!(expression, ns)
  NodeSelection.new(@element.find(expression, ns.map{|k,v| "#{k}:#{v}" }).to_a.map{|node| LibXMLDriver.new(node, ns) })
end