sax-machine
sax-machine copied to clipboard
Skipping all the child tags without raising any errors
In case the underlying XML is not valid. In my case, just having unescaped &
Gemfile:
source "https://rubygems.org"
gem "sax-machine"
gem "nokogiri"
test.rb:
require "sax-machine"
class Child
include SAXMachine
end
class Parent
include SAXMachine
elements :child, as: :children, class: Child
end
p Parent.parse(File.open("xml").read)
xml:
<?xml version="1.0"?>
<parent>
<child>
one &
</child>
<child>
two
</child>
</parent>
And it goes #<Parent:0x000055fef4541cc8>
without nor child elements nether error raised.