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)


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

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

#node_nameObject



208
209
210
# File 'lib/handsoap/xml_query_front.rb', line 208

def node_name
  @element.name
end

#to_rawObject



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

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

#to_sObject



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

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

#to_xmlObject



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

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

#xpath(expression, ns = nil) ⇒ Object



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

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