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)


221
222
223
224
# File 'lib/handsoap/xml_query_front.rb', line 221

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

#node_nameObject



212
213
214
# File 'lib/handsoap/xml_query_front.rb', line 212

def node_name
  @element.name
end

#to_rawObject



228
229
230
# File 'lib/handsoap/xml_query_front.rb', line 228

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

#to_sObject



231
232
233
234
235
236
237
# File 'lib/handsoap/xml_query_front.rb', line 231

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

#to_xmlObject



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

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

#xpath(expression, ns = nil) ⇒ Object



215
216
217
218
219
220
# File 'lib/handsoap/xml_query_front.rb', line 215

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