forked from NaturalIntelligence/fast-xml-parser
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
rename cdataTagName to cdataPropName & support comments
- Loading branch information
1 parent
f379c66
commit 45b912f
Showing
15 changed files
with
234 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
|
||
const { XMLParser, XMLBuilder, XMLValidator} = require("../src/fxp"); | ||
|
||
describe("Comments", function() { | ||
|
||
it("should parse comment and build them back", function() { | ||
const XMLdata = ` | ||
<!--Students grades are uploaded by months--> | ||
<class_list> | ||
<student> | ||
<!--Student details--> | ||
<!--A second comment--> | ||
<name>Tanmay</name> | ||
<grade>A</grade> | ||
</student> | ||
</class_list>`; | ||
|
||
const options = { | ||
ignoreAttributes: false, | ||
format: true, | ||
commentPropName: "#comment", | ||
preserveOrder: true | ||
}; | ||
const parser = new XMLParser(options); | ||
let result = parser.parse(XMLdata); | ||
// console.log(JSON.stringify(result, null,4)); | ||
|
||
const builder = new XMLBuilder(options); | ||
const output = builder.build(result); | ||
// console.log(output); | ||
expect(output.replace(/\s+/g, "")).toEqual(XMLdata.replace(/\s+/g, "")); | ||
}); | ||
|
||
|
||
}); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.