Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/phrogz/neatxml
JavaScript-based XML serialization with a few handy features.
https://github.com/phrogz/neatxml
Last synced: 7 days ago
JSON representation
JavaScript-based XML serialization with a few handy features.
- Host: GitHub
- URL: https://github.com/phrogz/neatxml
- Owner: Phrogz
- License: mit
- Created: 2018-11-13T04:55:29.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2019-04-21T20:01:37.000Z (over 5 years ago)
- Last Synced: 2024-10-26T12:31:31.849Z (13 days ago)
- Language: JavaScript
- Size: 5.86 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# NeatXML
NeatXML is XML serialization (in JavaScript) with a few handy features.The NeatXML module exports a single function, which takes an [XML Document](https://www.w3.org/TR/dom/#xml-document) or [Element](https://www.w3.org/TR/dom/#element) object to turn into a string, and an optional object specifying serialization options.
```js
import NeatXML from './neatxml.js';
const xmlString = NeatXML(xmlNodeOrDoc, options);
```The `options` object accepts the following keys and values:
* `indent`: if set to a number or string, each node in the supplied hierarchy will be placed on its own line and indented by the number of spaces (if a number) or by repetitions of the string specified by this option.
* `strip`: if set to `true`, remove leading/trailing whitespace from text nodes, and ignore whitespace-only nodes altogether.
* `sort`: if set to `true`, sort attributes within elements based on their name; attributes with no namespace will appear before those with a prefix.
* `omitNS`: if set to a namespace URI string, or array of URIs, all attributes, elements, and namespace declarations matching the URI(s) will be omitted from the output.
* `cdata`: if set to `true`, all text nodes will be output as CDATA sections; if set to `false`, all CDATA nodes will be output as plain text.
* `tightcdata`: if this and `indent` are `true`, cdata nodes will start and end on the same line on their parent, with their text content on separate line(s).When using the `indent` option you will likely also want to use the `strip` option.
## License & Contact
NeatXML is copyright ©2018 by Gavin Kistner and is released under
the [MIT License](http://www.opensource.org/licenses/mit-license.php).
See the LICENSE.txt file for more details.For bugs or feature requests please open [issues on GitHub](https://github.com/Phrogz/NeatXML/issues).
For other communication you can [email the author directly](mailto:[email protected]?subject=NeatXML).## TODO (aka Known Limitations)
* Set up a robust test suite.
* Provide options for wrapping to set column widths.
* Provide options for formatting numeric attributes to a number of decimals.## HISTORY
* **v0.10 [2019-Apr-21]** — Add `tightcdata` feature.
* **v0.9** — Initial release