fast-xml-parser 4.2.5 → 4.2.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -0
- package/README.md +20 -10
- package/package.json +2 -2
- package/src/xmlbuilder/json2xml.js +15 -5
- package/src/xmlparser/OrderedObjParser.js +1 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
Note: If you find missing information about particular minor version, that version must have been changed without any functional change in this library.
|
|
2
2
|
|
|
3
|
+
**4.2.7 / 2023-07-30**
|
|
4
|
+
* Fix: builder should set text node correctly when only textnode is present (#589) (By [qianqing](https://github.com/joneqian))
|
|
5
|
+
* Fix: Fix for null and undefined attributes when building xml (#585) (#598). A null or undefined value should be ignored. (By [Eugenio Ceschia](https://github.com/cecia234))
|
|
6
|
+
|
|
7
|
+
**4.2.6 / 2023-07-17**
|
|
8
|
+
* Fix: Remove trailing slash from jPath for self-closing tags (#595) (By [Maciej Radzikowski](https://github.com/m-radzikowski))
|
|
9
|
+
|
|
3
10
|
**4.2.5 / 2023-06-22**
|
|
4
11
|
* change code implementation
|
|
5
12
|
|
package/README.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
# [fast-xml-parser](https://www.npmjs.com/package/fast-xml-parser)
|
|
2
|
-
[](https://snyk.io/test/github/naturalintelligence/fast-xml-parser)
|
|
3
3
|
[![NPM quality][quality-image]][quality-url]
|
|
4
4
|
[](https://coveralls.io/github/NaturalIntelligence/fast-xml-parser?branch=master)
|
|
5
5
|
[<img src="https://img.shields.io/badge/Try-me-blue.svg?colorA=FFA500&colorB=0000FF" alt="Try me"/>](https://naturalintelligence.github.io/fast-xml-parser/)
|
|
@@ -11,20 +11,28 @@
|
|
|
11
11
|
|
|
12
12
|
Validate XML, Parse XML to JS Object, or Build XML from JS Object without C/C++ based libraries and no callback.
|
|
13
13
|
|
|
14
|
-
>
|
|
14
|
+
<font size="6">I need a Career advice. I've posted the query on my <a href="github.com/amitguptagwl">profile</a>. Your support would be appreciable.</font>
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
Sponsor this project 👉
|
|
17
|
+
<a href="https://github.com/sponsors/NaturalIntelligence">
|
|
18
|
+
<img src="https://raw.githubusercontent.com/NaturalIntelligence/ThankYouBackers/main/github_sponsor.png" width="200" />
|
|
19
|
+
</a>
|
|
19
20
|
<a href="https://opencollective.com/fast-xml-parser/donate" target="_blank">
|
|
20
21
|
<img src="https://opencollective.com/fast-xml-parser/donate/button@2x.png?color=blue" width=200 />
|
|
21
22
|
</a>
|
|
22
23
|
<a href="https://paypal.me/naturalintelligence"> <img src="static/img/support_paypal.svg" alt="Stubmatic donate button" width="200"/></a>
|
|
23
24
|
|
|
24
25
|
|
|
25
|
-
### Sponsors
|
|
26
|
+
### Current Sponsors
|
|
27
|
+
|
|
28
|
+
Check the complete list at [ThankYouBackers](https://github.com/NaturalIntelligence/ThankYouBackers) for our sponsors and supporters.
|
|
29
|
+
|
|
30
|
+
Through Github
|
|
26
31
|
|
|
27
32
|
<a href="https://github.com/getsentry" target="_blank"><img src="https://user-images.githubusercontent.com/7692328/204701653-ce369b29-6fdb-48f2-9848-593d04628a2b.png" width="60px"></a>
|
|
33
|
+
|
|
34
|
+
Through OpenCollective
|
|
35
|
+
|
|
28
36
|
<a href="https://opencollective.com/fast-xml-parser/sponsor/0/website" target="_blank"><img src="https://opencollective.com/fast-xml-parser/sponsor/0/avatar.svg"></a>
|
|
29
37
|
<a href="https://opencollective.com/fast-xml-parser/sponsor/1/website" target="_blank"><img src="https://opencollective.com/fast-xml-parser/sponsor/1/avatar.svg"></a>
|
|
30
38
|
<a href="https://opencollective.com/fast-xml-parser/sponsor/2/website" target="_blank"><img src="https://opencollective.com/fast-xml-parser/sponsor/2/avatar.svg"></a>
|
|
@@ -37,8 +45,6 @@ Click on Sponsor button above or
|
|
|
37
45
|
<a href="https://opencollective.com/fast-xml-parser/sponsor/9/website" target="_blank"><img src="https://opencollective.com/fast-xml-parser/sponsor/9/avatar.svg"></a>
|
|
38
46
|
|
|
39
47
|
|
|
40
|
-
Check [ThankYouBackers](https://github.com/NaturalIntelligence/ThankYouBackers) for our supporters
|
|
41
|
-
|
|
42
48
|
## Users
|
|
43
49
|
|
|
44
50
|
<a href="https://github.com/renovatebot/renovate" title="renovate" ><img src="https://avatars1.githubusercontent.com/u/38656520" width="60px" ></a>
|
|
@@ -56,9 +62,13 @@ Check [ThankYouBackers](https://github.com/NaturalIntelligence/ThankYouBackers)
|
|
|
56
62
|
<a href="https://github.com/postmanlabs" title="postman" > <img src="https://user-images.githubusercontent.com/7692328/204835529-e9e290ad-696a-49ad-9d34-08e955704715.png" width="60px" ></a>
|
|
57
63
|
<a href="https://github.com/react-native-community" title="React Native Community" > <img src="https://avatars.githubusercontent.com/u/20269980?v=4" width="60px" ></a>
|
|
58
64
|
|
|
59
|
-
Check the
|
|
65
|
+
Check the bigger [list](./USERs.md)
|
|
66
|
+
|
|
67
|
+
<small>The list of users is collected either from the list published by Github, communicated directly through mails/chat , or from other resources. If you feel that your name in the above list is incorrectly published or you're not the user of this library anymore then you can inform us to remove it. We'll do the necessary changes ASAP.</small>
|
|
60
68
|
|
|
61
|
-
|
|
69
|
+
If you want to be an anonymous user of this application and don't want to be highlighted anywhere then you can contact me at
|
|
70
|
+
- githubissues@proton.me
|
|
71
|
+
- https://linkedin.com/in/amitguptagwl/
|
|
62
72
|
|
|
63
73
|
## Main Features
|
|
64
74
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fast-xml-parser",
|
|
3
|
-
"version": "4.2.
|
|
3
|
+
"version": "4.2.7",
|
|
4
4
|
"description": "Validate XML, Parse XML, Build XML without C/C++ based libraries",
|
|
5
5
|
"main": "./src/fxp.js",
|
|
6
6
|
"scripts": {
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"json2xml",
|
|
40
40
|
"html"
|
|
41
41
|
],
|
|
42
|
-
"author": "Amit Gupta (https://
|
|
42
|
+
"author": "Amit Gupta (https://amitguptagwl.github.io)",
|
|
43
43
|
"license": "MIT",
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"@babel/core": "^7.13.10",
|
|
@@ -80,10 +80,19 @@ Builder.prototype.j2x = function(jObj, level) {
|
|
|
80
80
|
let val = '';
|
|
81
81
|
for (let key in jObj) {
|
|
82
82
|
if (typeof jObj[key] === 'undefined') {
|
|
83
|
-
// supress undefined node
|
|
83
|
+
// supress undefined node only if it is not an attribute
|
|
84
|
+
if (this.isAttribute(key)) {
|
|
85
|
+
val += '';
|
|
86
|
+
}
|
|
84
87
|
} else if (jObj[key] === null) {
|
|
85
|
-
|
|
86
|
-
|
|
88
|
+
// null attribute should be ignored by the attribute list, but should not cause the tag closing
|
|
89
|
+
if (this.isAttribute(key)) {
|
|
90
|
+
val += '';
|
|
91
|
+
} else if (key[0] === '?') {
|
|
92
|
+
val += this.indentate(level) + '<' + key + '?' + this.tagEndChar;
|
|
93
|
+
} else {
|
|
94
|
+
val += this.indentate(level) + '<' + key + '/' + this.tagEndChar;
|
|
95
|
+
}
|
|
87
96
|
// val += this.indentate(level) + '<' + key + '/' + this.tagEndChar;
|
|
88
97
|
} else if (jObj[key] instanceof Date) {
|
|
89
98
|
val += this.buildTextValNode(jObj[key], key, '', level);
|
|
@@ -176,7 +185,8 @@ Builder.prototype.buildObjectNode = function(val, key, attrStr, level) {
|
|
|
176
185
|
tagEndExp = "";
|
|
177
186
|
}
|
|
178
187
|
|
|
179
|
-
|
|
188
|
+
// attrStr is an empty string in case the attribute came as undefined or null
|
|
189
|
+
if ((attrStr || attrStr === '') && val.indexOf('<') === -1) {
|
|
180
190
|
return ( this.indentate(level) + '<' + key + attrStr + piClosingChar + '>' + val + tagEndExp );
|
|
181
191
|
} else if (this.options.commentPropName !== false && key === this.options.commentPropName && piClosingChar.length === 0) {
|
|
182
192
|
return this.indentate(level) + `<!--${val}-->` + this.newLine;
|
|
@@ -249,7 +259,7 @@ function indentate(level) {
|
|
|
249
259
|
}
|
|
250
260
|
|
|
251
261
|
function isAttribute(name /*, options*/) {
|
|
252
|
-
if (name.startsWith(this.options.attributeNamePrefix)) {
|
|
262
|
+
if (name.startsWith(this.options.attributeNamePrefix) && name !== this.options.textNodeName) {
|
|
253
263
|
return name.substr(this.attrPrefixLen);
|
|
254
264
|
} else {
|
|
255
265
|
return false;
|
|
@@ -341,6 +341,7 @@ const parseXml = function(xmlData) {
|
|
|
341
341
|
if(tagExp.length > 0 && tagExp.lastIndexOf("/") === tagExp.length - 1){
|
|
342
342
|
if(tagName[tagName.length - 1] === "/"){ //remove trailing '/'
|
|
343
343
|
tagName = tagName.substr(0, tagName.length - 1);
|
|
344
|
+
jPath = jPath.substr(0, jPath.length - 1);
|
|
344
345
|
tagExp = tagName;
|
|
345
346
|
}else{
|
|
346
347
|
tagExp = tagExp.substr(0, tagExp.length - 1);
|