Skip to content

Instantly share code, notes, and snippets.

@morgoth
Created August 7, 2012 18:37
Show Gist options
  • Save morgoth/3288154 to your computer and use it in GitHub Desktop.
Save morgoth/3288154 to your computer and use it in GitHub Desktop.
require "multi_xml"
# copy paste above xml document to `xml` variable
MultiXml.parser
# => MultiXml::Parsers::Ox
MultiXml.parse(xml).keys
# => ["aws:UrlInfoResponse"]
MultiXml.parser = :rexml
# => :rexml
MultiXml.parse(xml).keys
# => ["UrlInfoResponse"]
"<?xml version=\"1.0\"?>\n<aws:UrlInfoResponse xmlns:aws=\"http://alexa.amazonaws.com/doc/2005-07-11/\"><aws:Response xmlns:aws=\"http://awis.amazonaws.com/doc/2005-07-11\"><aws:OperationRequest><aws:RequestId>85b89e85-8579-74d4-f88d-33bbb4e4d536</aws:RequestId></aws:OperationRequest><aws:UrlInfoResult><aws:Alexa>\n \n <aws:ContactInfo>\n <aws:DataUrl type=\"canonical\">dupa.com</aws:DataUrl>\n <aws:PhoneNumbers>\n <aws:PhoneNumber>602 741 670</aws:PhoneNumber>\n </aws:PhoneNumbers>\n <aws:OwnerName>WebFabrika</aws:OwnerName>\n <aws:Email>wlochaty@dupa.com</aws:Email>\n <aws:PhysicalAddress>\n <aws:Streets>\n <aws:Street>Ul. Grzybowska 9 m.1419</aws:Street>\n </aws:Streets>\n <aws:City>Warszawa, Woj. Mazowieckie 00-132</aws:City>\n <aws:Country>POLAND</aws:Country>\n </aws:PhysicalAddress>\n <aws:CompanyStockTicker/>\n </aws:ContactInfo>\n <aws:ContentData>\n <aws:DataUrl type=\"canonical\">dupa.com</aws:DataUrl>\n <aws:SiteData>\n <aws:Title>WebFabrika</aws:Title>\n <aws:OnlineSince>01-Mar-1999</aws:OnlineSince>\n </aws:SiteData>\n <aws:Speed>\n <aws:MedianLoadTime/>\n <aws:Percentile/>\n </aws:Speed>\n <aws:AdultContent>no</aws:AdultContent>\n <aws:Language>\n <aws:Locale>pl</aws:Locale>\n <aws:Encoding>iso-8859-2</aws:Encoding>\n </aws:Language>\n <aws:LinksInCount>28</aws:LinksInCount>\n <aws:Keywords/>\n <aws:OwnedDomains/>\n </aws:ContentData>\n <aws:Related>\n <aws:DataUrl type=\"canonical\">dupa.com</aws:DataUrl>\n <aws:RelatedLinks>\n <aws:RelatedLink>\n <aws:DataUrl type=\"canonical\">www.promail.pl/</aws:DataUrl>\n <aws:NavigableUrl>http://www.promail.pl/</aws:NavigableUrl>\n <aws:Title>www.promail.pl/</aws:Title>\n </aws:RelatedLink>\n </aws:RelatedLinks>\n </aws:Related>\n <aws:TrafficData>\n <aws:DataUrl type=\"canonical\">dupa.com</aws:DataUrl>\n <aws:Rank>8776627</aws:Rank>\n <aws:RankByCountry/>\n <aws:RankByCity/>\n <aws:UsageStatistics>\n <aws:UsageStatistic>\n <aws:TimeRange>\n <aws:Months>3</aws:Months>\n </aws:TimeRange>\n <aws:Rank>\n <aws:Value>8776627</aws:Value>\n <aws:Delta>+963196</aws:Delta>\n </aws:Rank>\n <aws:Reach>\n <aws:Rank>\n <aws:Value>7526764</aws:Value>\n <aws:Delta>+885439</aws:Delta>\n </aws:Rank>\n <aws:PerMillion>\n <aws:Value>0.12</aws:Value>\n <aws:Delta>-20%</aws:Delta>\n </aws:PerMillion>\n </aws:Reach>\n <aws:PageViews>\n <aws:PerMillion>\n <aws:Value>0</aws:Value>\n <aws:Delta>-20%</aws:Delta>\n </aws:PerMillion>\n <aws:Rank>\n <aws:Value>11417545</aws:Value>\n <aws:Delta>984027</aws:Delta>\n </aws:Rank>\n <aws:PerUser>\n <aws:Value>1</aws:Value>\n <aws:Delta>0%</aws:Delta>\n </aws:PerUser>\n </aws:PageViews>\n </aws:UsageStatistic>\n </aws:UsageStatistics>\n <aws:ContributingSubdomains/>\n </aws:TrafficData>\n</aws:Alexa></aws:UrlInfoResult><aws:ResponseStatus xmlns:aws=\"http://alexa.amazonaws.com/doc/2005-07-11/\"><aws:StatusCode>Success</aws:StatusCode></aws:ResponseStatus></aws:Response></aws:UrlInfoResponse>"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment