nhu313 / Quinn

XML parser for Elixir
Other
49 stars 12 forks source link

xml-comments not parsed #7

Closed sportograf closed 6 years ago

sportograf commented 7 years ago

Hi,

first thanks for this cool engine. I've tried the following and it crashes

Quinn.parse("<head><title short_name = \"yah\">Yahoo</title><title:content>Bing</title:content><!-- foo --></head>"

with:

** (FunctionClauseError) no function clause matching in Quinn.XmlParser.parse_record/1
    lib/xml_parser/xml_parser.ex:20: Quinn.XmlParser.parse_record({:xmlComment, [head: 1], 3, [], ' foo '})
    lib/xml_parser/xml_parser.ex:39: Quinn.XmlParser.parse_record/1
    lib/xml_parser/xml_parser.ex:39: Quinn.XmlParser.parse_record/1
    lib/xml_parser/xml_parser.ex:21: Quinn.XmlParser.parse_record/1

thanks guido

nhu313 commented 7 years ago

Sorry, for the late reply. I don't get notify when an issue open. Thanks for reporting! I'll look over it this weekend.

nhu313 commented 7 years ago

Sorry, I looked it over the weekend, but realized it's not an easy fix. I will try again this weekend.

jaimeiniesta commented 7 years ago

I also run on this bug, it crashes when processing an XML like this:

<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
   <url>
      <loc>/</loc>
   </url>
   <url>
      <loc>/faqs</loc>
   </url>
   <url>
      <loc>/about</loc>
   </url>
   <!--
   <url>
      <loc>/commented-out-should-not-be-included</loc>
   </url>
   -->
</urlset>

Same error as above, posting this so we have more examples.

jaimeiniesta commented 7 years ago

I've replaced Quinn by Friendly (XML parser on top of Floki) and it works fine for the example in my comment above.

nhu313 commented 7 years ago

@sportograf I updated to 1.0.1. It is ignoring the comments for now. I have to figure out how to handle comments in the future. Sorry for the trouble. Lolz I have to agree with @jaimeiniesta I would choose another library, maybe Floki itself. I'm just not on top of these things, so if what you need is time sensitive, I would use another library.

@jaimeiniesta thanks for sample xml and the link to Friendly. Sorry for the trouble.

jaimeiniesta commented 7 years ago

Hey @nhu313 thanks for that! Not saying that Friendly is better than Quinn, it just works fine for my use case and didn't crash with comments :)

nhu313 commented 7 years ago

@jaimeiniesta no problem. I totally understand. If I have to choose a library, I would definitely choose one that works too 😆 and definitely one with a maintainer that is quick with bug fixes 😄

I'm leaving this open until I fix the comments thing.

nhu313 commented 6 years ago

Added the code to parse comments in pr #9 . thank you for reporting the issue @sportograf. Have a great week!