tags:

views:

140

answers:

1

I tried opening xml file using both the ways, but only the latter part worked when I tried to use xpath.

eg., doc = as in title;

   doc.xpath('//feed/xyz'), worked only when I open the file using parse method.

One thing I noted was, the object when I open using XML:: is Nokogiri::XML::Document, while the latter one was Nokogiri::HTML::Document

Any comments?

+1  A: 

Nokogiri.parse parses HTML documents, while Nokogiri::XML expects valid XML document. it seems that when XML parsing fails, error is not raised, rather an empty XML document is generated. try puts doc.to_s, you'll probably see "<?xml version=\"1.0\"?>\n"

mykhal
yes! thats true! Just wondering why, coz I don see any error as such in the XML doc. Opens fine in a browser.
Gim