Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
useful class for matching xml documents based on a subset of nodes
Ruby
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
lib
spec
MIT-LICENSE
README
xml_subset_matcher.gemspec

README

Contributors:
Sarah Allen, http://github.com/ultrasaurus
Wolfram Arnold, http://github.com/wolframarnold 
Nikolay, http://github.com/jastix

Build and install the gem:
  gem build xml_subset_matcher.gemspec
  sudo gem install xml_subset_matcher

run the specs (all pass)
  spec spec/lib/xml_subset_matcher_spec.rb

using the library
$ irb
>> require 'xml_subset_matcher'
=> true
>> subset = "<root><thing>text</thing></root>"
=> "<root><thing>text</thing></root>"
>> superset = "<root extra='stuff'><ignorethis/><thing>text</thing></root>"
=> "<root extra='stuff'><ignorethis/><thing>text</thing></root>"
>> x = XmlSubsetMatcher::XmlSubsetMatcher.new(superset)
=> #<XmlSubsetMatcher::XmlSubsetMatcher:0x55a514 @error="", @superset=<?xml version="1.0" encoding="UTF-8"?>
<root extra="stuff">
  <ignorethis/>
  <thing>text</thing>
</root>
>
>> x.matches?(subset)
=> true
>> subset = "<something>else</something>"
=> "<something>else</something>"
>> x.matches?(subset)
=> false
Something went wrong with that request. Please try again.