Module: HS::XMLParser
- Included in:
- ChapterLoader, CourseLoader, ModuleLoader
- Defined in:
- lib/hs/loaders/xml_parser.rb
Instance Method Summary collapse
-
#get_text(object) ⇒ Object
Text content of the node.
- #parse_xml(xml) ⇒ Object
Instance Method Details
#get_text(object) ⇒ Object
Text content of the node. Note, that we don’t go deep into element tree.
18 19 20 |
# File 'lib/hs/loaders/xml_parser.rb', line 18 def get_text(object) object[:_children].map { |obj| obj[:text] }.compact.join(' ') end |
#parse_xml(xml) ⇒ Object
8 9 10 11 12 13 14 |
# File 'lib/hs/loaders/xml_parser.rb', line 8 def parse_xml(xml) doc = Nokogiri::XML(xml) do |config| config. = Nokogiri::XML::ParseOptions::STRICT end to_object_notation(doc.root) end |