Class: Mechanize::XmlFile
- Extended by:
- Forwardable
- Defined in:
- lib/mechanize/xml_file.rb
Overview
This class encapsulates an XML file. If Mechanize finds a content-type of ‘text/xml’ or ‘application/xml’ this class will be instantiated and returned. This class also opens up the search
and at
methods available on the underlying Nokogiri::XML::Document object.
Example:
require 'mechanize'
agent = Mechanize.new
xml = agent.get('http://example.org/some-xml-file.xml')
xml.class #=> Mechanize::XmlFile
xml.search('//foo[@attr="bar"]/etc')
Constant Summary
Constants included from Parser
Instance Attribute Summary collapse
-
#xml ⇒ Object
readonly
:method: at.
Attributes inherited from File
Attributes included from Parser
Instance Method Summary collapse
-
#initialize(uri = nil, response = nil, body = nil, code = nil) ⇒ XmlFile
constructor
A new instance of XmlFile.
Methods inherited from File
Methods included from Parser
#extract_filename, #fill_header, #find_free_name
Constructor Details
#initialize(uri = nil, response = nil, body = nil, code = nil) ⇒ XmlFile
Returns a new instance of XmlFile.
24 25 26 27 |
# File 'lib/mechanize/xml_file.rb', line 24 def initialize(uri = nil, response = nil, body = nil, code = nil) super uri, response, body, code @xml = Nokogiri.XML body end |
Instance Attribute Details
#xml ⇒ Object (readonly)
:method: at
Search through the page for path
under namespace
using Nokogiri’s #at. The path
may be either a CSS or XPath expression.
See also Nokogiri::XML::Node#at
22 23 24 |
# File 'lib/mechanize/xml_file.rb', line 22 def xml @xml end |