Class: Prestashopper::Product
- Inherits:
-
Object
- Object
- Prestashopper::Product
- Defined in:
- lib/prestashopper/product.rb
Overview
Has methods to convert the XML returned from the API to a ruby hash
Class Method Summary collapse
-
.xml2hash(xml) ⇒ Hash
Convert a product XML returned by the Prestashop API to a ruby hash, more manageable.
Class Method Details
.xml2hash(xml) ⇒ Hash
Convert a product XML returned by the Prestashop API to a ruby hash, more manageable
11 12 13 14 15 16 17 18 19 |
# File 'lib/prestashopper/product.rb', line 11 def self.xml2hash(xml) xml_doc = Nokogiri::XML( xml).remove_namespaces! # Strip surrounding tag nodes = xml_doc.xpath '/prestashop/*' product_xml = nodes.to_s product_hash = Hash.from_xml product_xml return product_hash['product'] end |