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

- (Object) [](attribute_name)

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

- (Object) children



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

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

- (Object) node_name



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

def node_name
  @element.name
end

- (Object) node_namespace



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

- (Object) to_raw



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

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

- (Object) to_s



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

- (Object) to_xml



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

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

- (Object) xpath(expression, ns = nil)



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