Giter Club home page Giter Club logo

node-xml-lite's People

Contributors

hgourvest avatar lorcanmcdonald avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

node-xml-lite's Issues

Significant space is being stripped.

For example, if I parse

<li>I've talked with a lot of <country>Cuba</country> people.</li>

it yields the following JSON

{ name: 'li',
  childs: [
    'I\'ve talked with a lot of ',
    { name: 'country', childs: ['Cuba'] },
    'people.'
  ]
}

Notice how the space between "Cuba" and "people" is stripped out. Is this the intended behavior? Is there a workaround for this?

Stripping new lines from content

The parser is stripping \r\n characters from values that are not wrapped in CDATA tags.

Is there a particular reason for that?

toString() missing

That would be great to implement a toString method, so that this code would return the string representation of the xml

var xmlParser = require('node-xml-lite');
var xmlData = '<div><b>hello</b><ul><li>world</li><li>hi</li></ul></div>';
parsedData = xmlParser.parseString(xmlData);
console.log(parsedData.toString(), xmlData);

Rejects valid XML Names

The parser rejects this svg file because it expects attribute names to be alphanumeric, which stroke-width is not.

There are many other characters which are allowed in an XML Name, listed in the spec (see: Names and Tokens) which don't seem to be supported...

character missing if comment contains '-' character

If you have a comment like this

<!--comment-with-hyphen-->

the output string will be

commentithyphen

the '-' character and the character after it will be missing.

here is a simple code to demonstrate it

var xml = require('node-xml-lite');
var fs = require('fs');

function parseFunc (state, a, b) {
    switch (state) {
        case xml.xtComment:
            console.log(a);
            break;
    }
    return true;
}

fs.writeFile('bug.xml', '<!-- comment-with-hyphen -->', function(err, data) {
    fs.readFile('bug.xml', 'utf8', function(err, data) {
        // file output
        console.log(data);
        // parser output
        xml.SAXParseFile('bug.xml', parseFunc);
    });
});
// output
// <!-- comment-with-hyphen -->
// commentithyphen 

V0.0.4 Error when XML with commont before root tag

xml file like this

<!-- Error -->
<?xml version="1.0" encoding="utf-8"?>
<!-- Error -->
<svg width="40" height="32" viewBox="0 0 40 32">
<!-- Works -->
<ellipse  cx="20" cy="16" rx="20" ry="16"/>
</svg>
<!-- Works -->

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.