Skip to content

Instantly share code, notes, and snippets.

@djberg96
Created July 20, 2016 20:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save djberg96/9bd301987a328ce693c50eb237e88721 to your computer and use it in GitHub Desktop.
Save djberg96/9bd301987a328ce693c50eb237e88721 to your computer and use it in GitHub Desktop.
require 'nokogiri'
require 'oga'
xml = %Q{<?xml version="1.0" encoding="utf-8"?><StorageServiceProperties><Logging><Version>1.0</Version><Read>false</Read><Write>false</Write><Delete>false</Delete><RetentionPolicy><Enabled>false</Enabled></RetentionPolicy></Logging><HourMetrics><Version>1.0</Version><Enabled>true</Enabled><IncludeAPIs>true</IncludeAPIs><RetentionPolicy><Enabled>true</Enabled><Days>7</Days></RetentionPolicy></HourMetrics><MinuteMetrics><Version>1.0</Version><Enabled>false</Enabled><RetentionPolicy><Enabled>false</Enabled></RetentionPolicy></MinuteMetrics><Cors /></StorageServiceProperties>}
top = "StorageServiceProperties"
p Nokogiri::XML(xml).xpath("//#{top}").to_s # => "<StorageServiceProperties>\n <Logging>\n ..., etc
p Oga.parse_xml(xml).xpath("//#{top}").to_s # => "#<Oga::XML::NodeSet:0x007fb0e3910280>"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment