Comments (14)
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.
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.
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.
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.
you're doing the parsing in a bit of a silly manner
😄
Would appreciate if you can submit a pull request.
from xml-js.
Ah, I didn't mean to offend!
Either way, I'll give it a go in a bit. :-)
from xml-js.
No not at all. I didn't feel offended by this. I just liked the way you phrased it and laughed.
from xml-js.
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.
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.
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.
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.
You can revert the revert if you don't mind a tiny typo (forgot to close parenthesis) in your git history.
from xml-js.
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.
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)
- Wrong Handling of Whitespaces & Line breaks HOT 1
- "'" being changed to single quote HOT 2
- How to traverse through every tag
- `attributeNameFn` callback receives an undefined attributeValue
- CRLF line endings cause scripts failures HOT 1
- _attributes gets added to _attributes?
- Empty String of nativeTypeAttributes converted zero HOT 3
- Removing all _cdata _attributes text
- XML-JS Empty xml files being made after conversion from .json file HOT 1
- Typescript: `_comment` does not accept string[]
- attributes escape character?
- Consider type "string" as a default for all the values
- Analysis: 100% of dependency updates in this repository can be merged. HOT 1
- XML > JSON: How do I 'intercept' processing of a specific node?
- JSON -> XML convert with CDATA support
- json to xml: Auto convert < to <
- return parsed object instead of string ? HOT 1
- No nativeTypeAttributes in index.d.ts
- Assignment I was given,kindly give me both the XML code to build the app interface and the java code to execute it
- Module not found: Error: Can't resolve 'buffer'
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from xml-js.