Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mergeAttrs true behaviour changes #110

Open
otemnov opened this issue Nov 24, 2013 · 9 comments
Open

mergeAttrs true behaviour changes #110

otemnov opened this issue Nov 24, 2013 · 9 comments
Assignees

Comments

@otemnov
Copy link

otemnov commented Nov 24, 2013

Not sure what is changed in latest release but before following xmlUrl attribute was parsed as single string. Now it is parsed as array.
Input:

<outline xmlUrl="http://www.futurity.org/feed/"/>

Output:

{
     'xmlUrl': [ 
        'http://www.futurity.org/feed', 
        pathname: '/' 
    ]
}

is it expected behaviour/change?

@Leonidas-from-XIV
Copy link
Owner

Which xmlUrl attribute? If this changed, this only changed in the 0.1 to 0.2 transition.

@otemnov
Copy link
Author

otemnov commented Nov 24, 2013

Here is example of xml tag:

<outline xmlUrl="http://www.futurity.org/feed/"/>

@otemnov
Copy link
Author

otemnov commented Nov 24, 2013

I'm using heroku so after today deploy it stoped work as before becasue of provided xml is parsed as

{ xmlUrl: [ 'http://www.futurity.org/feed', pathname: '/' ] }

it was expected to be just

{ xmlUrl: 'http://www.futurity.org/feed' }

heroku do clear npm install every release, so I did not catch it locally
previous release was 4 days ago

@otemnov
Copy link
Author

otemnov commented Nov 24, 2013

evenmore - looks like every tag attributes are parsed now as array

@Leonidas-from-XIV
Copy link
Owner

Can't reproduce at all:

{parseString} = require 'xml2js'
xml = '<outline htmlUrl="futurity.org" text="Futurity.org" title="Futurity.org" type="rss" xmlUrl="http://www.futurity.org/feed/"/>'
parseString xml, (err, result) ->
    console.dir result

Parses correctly to:

{ outline: 
   { '$': 
      { htmlUrl: 'futurity.org',
        text: 'Futurity.org',
        title: 'Futurity.org',
        type: 'rss',
        xmlUrl: 'http://www.futurity.org/feed/' } } }

Please provide example code to reproduce your issue.

@otemnov
Copy link
Author

otemnov commented Nov 24, 2013

looks like it is related to mergeAttrs setting

var xml2js = require('xml2js');
var parser = new xml2js.Parser({
    mergeAttrs: true
});
parser.parseString('<outline xmlUrl="http://www.futurity.org/feed/"/>', function (err, result) {
    console.dir(result);
});

@Leonidas-from-XIV
Copy link
Owner

Alright, that would have shortened the search. Check what happened in #101.

@otemnov
Copy link
Author

otemnov commented Nov 24, 2013

oki, thanks for help. Did not get initially that is could be related to mergeAttrs.
Probably could be good to add #101 as breaking change

@Leonidas-from-XIV
Copy link
Owner

Yes, I agree. I should add that to the readme.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants