Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ gb = GreenButton.load_xml_from_file('PATH/TO/FILE.XML')

# To load from URL:
gb = GreenButton.load_xml_from_web('https://services.greenbuttondata.org/DataCustodian/espi/1_1/resource/Batch/RetailCustomer/3/UsagePoint')

# To load from string:
gb = GreenButton.load_xml_from_string(xml_string)
```

This code will load the Green Button XML from the given file or URL and parse it into a series of Ruby objects representing the data contained in the file.
Expand Down
7 changes: 6 additions & 1 deletion lib/greenbutton.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,12 @@ def self.load_xml_from_file(path)
xml_file.remove_namespaces!
Parser.new(xml_file)
end


def self.load_xml_from_string(string)
xml_file = Nokogiri::XML.parse(string)
xml_file.remove_namespaces!
Parser.new(xml_file)
end

class Parser
attr_accessor :doc, :usage_points
Expand Down
1 change: 0 additions & 1 deletion lib/greenbutton/gb_classes.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
module GreenButtonClasses
require_relative 'helpers.rb'
require 'nokogiri'
require 'pry'

Rule = Helper::Rule
RULES = {
Expand Down