Module: XmlParsingHelper
- Included in:
- Rubillow::Models::Base, Rubillow::Models::DeepSearchResult
- Defined in:
- lib/rubillow/helpers/xml_parsing_helper.rb
Overview
Helper methods for parsing XML.
Instance Method Summary collapse
-
#xpath_if_present(path, attribute, xml, nil_value = nil) ⇒ String
is nil or if the node is not present.
Instance Method Details
#xpath_if_present(path, attribute, xml, nil_value = nil) ⇒ String
is nil or if the node is not present.
If the node is not present, return nil or nil_value if specified.
11 12 13 14 |
# File 'lib/rubillow/helpers/xml_parsing_helper.rb', line 11 def xpath_if_present(path, attribute, xml, nil_value = nil) text = xml.xpath(path).first.send(attribute) unless xml.xpath(path).empty? text ||= nil_value end |