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)


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

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

#childrenObject



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

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

#node_nameObject



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

def node_name
  @element.name
end

#to_rawObject



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

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

#to_sObject



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

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

#to_xmlObject



232
233
234
# File 'lib/handsoap/xml_query_front.rb', line 232

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

#xpath(expression, ns = nil) ⇒ Object



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

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