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_big_decimal, #to_boolean, #to_date, #to_f, #to_i

Instance Method Details

#[](attribute_name) ⇒ Object

Raises:

  • (ArgumentError)


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

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

#childrenObject



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

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

#node_nameObject



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

def node_name
  @element.name
end

#node_namespaceObject



238
239
240
241
242
243
244
# File 'lib/handsoap/xml_query_front.rb', line 238

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

#to_rawObject



261
262
263
# File 'lib/handsoap/xml_query_front.rb', line 261

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

#to_sObject



264
265
266
267
268
269
270
# File 'lib/handsoap/xml_query_front.rb', line 264

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

#to_xmlObject



258
259
260
# File 'lib/handsoap/xml_query_front.rb', line 258

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

#xpath(expression, ns = nil) ⇒ Object



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

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