Class: RoyalMailApi::XmlParser
- Inherits:
-
Object
- Object
- RoyalMailApi::XmlParser
- Defined in:
- lib/royal_mail_api/xml_parser.rb
Instance Method Summary collapse
Instance Method Details
#parse(xml, attr) ⇒ Object
3 4 5 6 7 8 9 10 |
# File 'lib/royal_mail_api/xml_parser.rb', line 3 def parse(xml, attr) unless xml.is_a? Nokogiri::XML::Element xml = Nokogiri::XML(xml).remove_namespaces! end # xpath method doesn't work for finding SOAP Fault attributes for some reason xml.css(attr) end |
#parse_all(xml, attr) ⇒ Object
12 13 14 |
# File 'lib/royal_mail_api/xml_parser.rb', line 12 def parse_all(xml, attr) parse(xml, "//#{attr}") end |
#parse_text(xml, attr) ⇒ Object
16 17 18 |
# File 'lib/royal_mail_api/xml_parser.rb', line 16 def parse_text(xml, attr) parse(xml, attr).text end |