Skip to content

Commit

Permalink
fix multiple root elements
Browse files Browse the repository at this point in the history
## Why?

XML with multiple root elements is invalid.

See: #160 (comment)
  • Loading branch information
naitoh committed Jul 3, 2024
1 parent face9dd commit c4fb89b
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions test/test_pullparser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,23 +63,23 @@ def test_entity_replacement
end

def test_character_references
source = '<a>&#65;</a><b>&#x42;</b>'
source = '<root><a>&#65;</a><b>&#x42;</b></root>'
parser = REXML::Parsers::PullParser.new( source )

events = {}
element_name = ''
while parser.has_next?
event = parser.pull
case event.event_type
when :start_element
element_name = event[0]
when :text
case element_name
when 'a'
assert_equal('A', event[1])
when 'b'
assert_equal('B', event[1])
end
events[element_name] = event[1]
end
end

assert_equal('A', events['a'])
assert_equal("B", events['b'])
end

def test_text_content_with_line_breaks
Expand Down

0 comments on commit c4fb89b

Please sign in to comment.