Class: ARII::XMLSeedReader
- Inherits:
-
SeedReader
- Object
- SeedReader
- ARII::XMLSeedReader
- Defined in:
- lib/arii/xmlseedreader.rb
Overview
XMLSeedReader
Load content from XML seed.
Instance Attribute Summary
Attributes inherited from SeedReader
Instance Method Summary collapse
-
#read ⇒ Object
Read.
Methods inherited from SeedReader
Constructor Details
This class inherits a constructor from ARII::SeedReader
Instance Method Details
#read ⇒ Object
Read
> Load the seed data into the @objects array for processing.
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/arii/xmlseedreader.rb', line 13 def read begin @doc = Nokogiri::XML(open(@seed[:payload][:uri])) @doc.remove_namespaces! @doc.xpath(@seed[:payload][:query]).each do |element| begin object = @help.deep_copy @agent[:payload] object.each_pair do |key, value| variables = @help.identify_variables(object[key]) variables.each do |v| element.xpath(@seed[:payload][:selectors][v]).each do |el| object[key].gsub!("%{#{v}}", el.content) end end end unless @seed[:payload][:cache].nil? then element.xpath(@seed[:payload][:cache]).each do |el| object[:seed] = el.content end else element.xpath('id').each do |el| object[:seed] = el.content end end object[:identifier] = @agent.identifier @objects.push object rescue Exception => e end end rescue Exception => e end @objects end |