sax-machine icon indicating copy to clipboard operation
sax-machine copied to clipboard

Skipping all the child tags without raising any errors

Open apsheronets opened this issue 2 years ago • 0 comments

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.

apsheronets avatar Sep 03 '22 16:09 apsheronets