You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+47-13Lines changed: 47 additions & 13 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -24,7 +24,7 @@ XML-Serializer is a complete JavaScript implementation of the W3C [xml serializa
24
24
25
25
## Module Availability
26
26
27
-
This module is available as an [npm](https://www.npmjs.com/) scoped package and also has a browser build that is located inside the `dist` folder. It can easily be integrated with [JSDOM](https://github.com/jsdom/jsdom) for mockup testing.
27
+
This module is available as an [npm](https://www.npmjs.com/package/@harrison-ifeanyichukwu/xml-serializer) scoped package and also has a browser build that is located inside the `dist` folder. It can easily be integrated with [JSDOM](https://github.com/jsdom/jsdom) for mockup testing.
following the specification, the `XMLSerializer` interface is a constructor and has a `serializeToString(root)` method exposed on the instance. To serialize any xml node, call the `serializeToString(root)` method on a constructed instance, passing in the xml node as below
41
+
Following the specification, the `XMLSerializer` interface is a constructor and has a `serializeToString(root)` method exposed on the instance. To serialize any xml node, call the `serializeToString(root)` method on a constructed instance, passing in the xml node as like shown below:
The constructor can take a boolean argument that indicates if whitespace should be preserved in the serialized output. Default value is `true`;
51
+
52
+
```javascript
53
+
// do not preserve white space
54
+
let instance =newXMLSerializer(false);
55
+
let xmlString =instance.serializeToString(document);
56
+
```
57
+
50
58
### Using with [JSDOM](https://github.com/jsdom/jsdom)
51
59
52
60
Currently, JSDOM has not implemented the `XMLSerializer` interface. This can be easily integrated with JSDOM and any other similar mockup environment or for web scrapping and xml feed parsing like below.
The browser build is available inside the dist folder. It exposes the `XMLSerialzer` construct on the `window` object.
76
+
The browser build is available inside the `dist` folder when you npm install the package. You can also this repo and run the build command locally. It exposes an `XMLSerializer` construct on the `window` object.
By default, the serializer preserves white space during the serialization process. This can be turned off by passing in false to the constructor at the time of creating an instance.
88
+
By default, the serializer preserves white space during the serialization process. This can be turned off if you want a compact output by passing in `false` to the constructor at the time of creating an instance.
75
89
76
90
```javascript
77
-
let instance =newXMLSerializer(false) // preserveWhiteSpace is set to false. it wont
78
-
//preserve white spaces
91
+
//do not preserve white space
92
+
let instance =newXMLSerializer(false);
79
93
```
80
94
81
-
Another improvement is that it removes all duplicate prefix definition on any xml element as recommended in the specification document unlike what web browsers do. Below is an example of
95
+
Another improvement is that it removes all duplicate xml prefix definition on as recommended in the specification document unlike what web browsers do. Below is an example of
82
96
this:
83
97
84
98
**Original XML**:
@@ -239,8 +253,28 @@ Notice that all of the duplicated namespaces are removed.
239
253
</root>
240
254
```
241
255
256
+
## Contributing
257
+
258
+
We welcome your own contributions, ranging from code refactoring, documentation improvements, new feature implementations, bugs/issues reporting, etc. We recommend you follow the steps below to actively contribute to this project:
259
+
260
+
1. Decide on what to help us with.
261
+
262
+
2. Fork this repo to your machine.
263
+
264
+
3. Implement your ideas, and once stable,
265
+
266
+
4. Create a pull request, explaining your improvements/features
267
+
268
+
All future contributors will be included below and immensely appreciated. We look forward to your contributions.
269
+
270
+
## About Project Maintainers
271
+
272
+
This project is maintained by [harrison ifeanyichukwu](mailto:[email protected]), a young, passionate full stack web developer, an [MDN](https://developer.mozilla.org/en-US/profiles/harrison-feanyichukwu) documentator, maintainer of node.js [rollup-all](https://www.npmjs.com/package/rollup-all) project, [R-Server](https://github.com/harrison-ifeanyichukwu/r-server) (a web server project), and other amazing projects.
273
+
274
+
He is available for hire, ready to work on `PHP` projects, `Node.js` projects, `React` and `Angular` projects and stuffs like that. Looks forward to hearing from you soon!!!
275
+
242
276
## Acknowledgments
243
277
244
278
In addition to the spec, the following sections as well as outside resources were consulted and proved very useful:
0 commit comments