Code Monkey home page Code Monkey logo

Comments (14)

nashwaan avatar nashwaan commented on May 31, 2024

While this xml is legal <?xml version='1.0' encoding='UTF-8'?>, unfortunately, the underlying sax parser which this library is depending on, doesn't seem to support single quotes attribute values.

Therefore, I suggest you try to do manual cleanup (by converting single quotes to double quotes) before passing the xml input to this library.

from xml-js.

YarnSphere avatar YarnSphere commented on May 31, 2024

Actually, I think this is on you; from reading through sax's source, it seems to support single quotes, it just doesn't parse instructions.

You're the one doing the parsing inside this function: https://github.com/nashwaan/xml-js/blob/master/lib/xml2js.js#L96.

Your regular expression is likely the issue, I'll give it a look.

from xml-js.

nashwaan avatar nashwaan commented on May 31, 2024

Yes, you are right. This part of parsing is done by this library not sax.
🤦

I feel there is something wrong with this line https://github.com/nashwaan/xml-js/blob/master/lib/xml2js.js#L100
I need to investigate this.

from xml-js.

YarnSphere avatar YarnSphere commented on May 31, 2024

The regexp itself seems correct, but you're doing the parsing in a bit of a silly manner, I think!
I'd likely set the global g flag on the regexp and iterate the resulting array after calling match.

from xml-js.

nashwaan avatar nashwaan commented on May 31, 2024

you're doing the parsing in a bit of a silly manner

😄

Would appreciate if you can submit a pull request.

from xml-js.

YarnSphere avatar YarnSphere commented on May 31, 2024

Ah, I didn't mean to offend!

Either way, I'll give it a go in a bit. :-)

from xml-js.

nashwaan avatar nashwaan commented on May 31, 2024

No not at all. I didn't feel offended by this. I just liked the way you phrased it and laughed.

from xml-js.

YarnSphere avatar YarnSphere commented on May 31, 2024

Okay, found the issue.
It's actually this line: https://github.com/nashwaan/xml-js/blob/master/lib/xml2js.js#L104
It must be: attributes[attribute[1]] = attribute[2] || attribute[3] || attribute[4]; to fetch the value from either of the capturing patterns. You were currently only fetching from the first capturing pattern (which is the double quotes).

I'll submit a PR shortly with a simpler way of doing the parsing, I had actually expressed myself poorly previously; I'll show you what I meant.

from xml-js.

YarnSphere avatar YarnSphere commented on May 31, 2024

Ignore the latest push, it was just me experimenting with fixing the commit message where I forgot to close the parenthesis. :-)

Just to know, will you publish to npm anytime soon?

from xml-js.

nashwaan avatar nashwaan commented on May 31, 2024

I merged your pull request because it passed the tests, and then revert it based on your last comment.

Yes, I was planning to release a fix release to npm shortly after the merge.

So, are going to submit another pull request?

from xml-js.

YarnSphere avatar YarnSphere commented on May 31, 2024

Ah, gosh, you didn't have to do that, I deleted my fork already!
It was just a typo in the commit message, and since I had never tried to fix one after submitting a PR I wondered what would happen.

Sorry about that!

from xml-js.

YarnSphere avatar YarnSphere commented on May 31, 2024

You can revert the revert if you don't mind a tiny typo (forgot to close parenthesis) in your git history.

from xml-js.

nashwaan avatar nashwaan commented on May 31, 2024

I hate git system as I never managed to understand how the pull/push/merge/branches work. I expect something, and then something else actually happens.
Today, I just hate it more. Near infinity.

But I somehow managed to release it to npm as v1.5.2.

Thanks for your contribution.

from xml-js.

YarnSphere avatar YarnSphere commented on May 31, 2024

I get you, I chuckled at the "Revert Revert"!

Thank you for your quick handling of stuff (and overall useful project)!

from xml-js.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.