Module: Nexpose::XMLUtils
- Included in:
- APIRequest, AdhocReportConfig, Connection, Credential, DiscoveryConnection, Field, HTMLForm, HTMLForms, Header, Headers
- Defined in:
- lib/nexpose/util.rb
Class Method Summary collapse
-
.success?(xml_string) ⇒ Boolean
Check a typical Nexpose XML response for success.
Instance Method Summary collapse
Class Method Details
.success?(xml_string) ⇒ Boolean
Check a typical Nexpose XML response for success. Typically, the root element has a ‘success’ attribute, and its value is ‘1’ if the call succeeded.
42 43 44 45 46 |
# File 'lib/nexpose/util.rb', line 42 def self.success?(xml_string) xml = ::REXML::Document.new(xml_string.to_s) success = ::REXML::XPath.first(xml, '//@success') !success.nil? && success.value.to_i == 1 end |
Instance Method Details
#make_xml(name, opts = {}, data = '', append_session_id = true) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/nexpose/util.rb', line 21 def make_xml(name, opts = {}, data = '', append_session_id = true) xml = REXML::Element.new(name) if @session_id and append_session_id xml.attributes['session-id'] = @session_id end opts.keys.each do |k| if opts[k] != nil xml.attributes[k] = "#{opts[k]}" end end xml.text = data xml end |
#parse_xml(xml) ⇒ Object
17 18 19 |
# File 'lib/nexpose/util.rb', line 17 def parse_xml(xml) ::REXML::Document.new(xml.to_s) end |