Skip to the Main Content

Note:These pages make extensive use of the latest XHTML and CSS Standards. They ought to look great in any standards-compliant modern browser. Unfortunately, they will probably look horrible in older browsers, like Netscape 4.x and IE 4.x. Moreover, many posts use MathML, which is, currently only supported in Mozilla. My best suggestion (and you will thank me when surfing an ever-increasing number of sites on the web which have been crafted to use the new standards) is to upgrade to the latest version of your browser. If that's not possible, consider moving to the Standards-compliant and open-source Mozilla browser.

December 17, 2013

Fun with Ruby XML Parsers

It’s 2013.

REXML:

irb(main):001:0> require 'rexml/document'
=> true
irb(main):002:0> REXML::Document.new("<!-- declarations for <head> & <body> -->")
=> <UNDEFINED> ... </>

Nokogiri:

irb(main):001:0> require 'nokogiri'
=> true
irb(main):002:0> puts Nokogiri::XML::Document.parse('<!-- -- -->').to_xml
<?xml version="1.0"?>
<!-- -- -->
=> nil

Hpricot:

irb(main):001:0> require 'hpricot'
=> true
irb(main):002:0> puts Hpricot::XML("<!-- -- -->")
<!-- -- -->
=> nil

Seriously?

Posted by distler at December 17, 2013 2:46 AM

TrackBack URL for this Entry:  

0 Comments & 0 Trackbacks

Post a New Comment