Rexleparser is an XML parser used by the Rexle gem
Homepage Rubygems Ruby Documentation Download
gem install rexleparser -v 0.1.8
README ------ Examples -------- require 'rexleparser' # 1) validate typical XML urls =<<URL <urls><summary><recordx_type>dynarex</recordx_type><format_mask>[!short_url] [!full_url]</format_mask><schema>urls/url(short_url,full_url)</schema></summary><records><url created="2010-10-11 21:11:16 +0100" id="2" last_modified="2010-10-13 15:20:58 +0100"><short_url>aa</short_url><full_url>http://www.wired.com/</full_url></url></records></urls> URL doc = Rexle.new(urls) # 2) validate XML containing newline characters require '/home/james/learning/ruby/rexle' urls =<<URL <urls> <summary><recordx_type>dynarex</recordx_type><format_mask>[!short_url] [!full_url]</format_mask> <schema>urls/url(short_url,full_url)</schema> </summary><records><url created="2010-10-11 21:11:16 +0100" id="2" last_modified="2010-10-13 15:20:58 +0100"> <short_url>aa</short_url><full_url>http://www.wired.com/</full_url></url></records></urls> URL doc = Rexle.new(urls) # 3) validate XML containing a processing instruction urls =<<URLS <?xml version="1.0" encoding="UTF-8"?> <urls> <summary> <recordx_type>dynarex</recordx_type> <format_mask>[!short_url] [!full_url]</format_mask> <schema>urls/url(short_url,full_url)</schema> </summary> <records> <url created="2010-10-11 21:11:16 +0100" id="2" last_modified="2010-10-13 15:20:58 +0100"> <short_url>aa</short_url> <full_url>http://www.wired.com/</full_url> </url> <url created="2010-10-11 21:11:16 +0100" id="3" last_modified="2010-10-13 17:07:46 +0100"> <short_url>ae</short_url> <full_url>http://forrst.com/posts/Introducing_the_shortn</full_url> </url> </records> </urls> URLS doc = RexleParser.new(urls)