Security News
Cloudflare Adds Security.txt Setup Wizard
Cloudflare has launched a setup wizard allowing users to easily create and manage a security.txt file for vulnerability disclosure on their websites.
@wmfs/xml2csv
Advanced tools
Takes an XML file and transforms it into a CSV file, based on format of the map you provide with options.
$ npm install @wmfs/xml2csv --save
const xml2csv = require('@wmfs/xml2csv')
xml2csv(
{
xmlPath: 'path/to/file.xml',
csvPath: 'path/to/file.csv',
rootXMLElement: 'Person',
headerMap: [
['Name', 'name', 'string'],
['Age', 'age', 'integer'],
['Gender', 'gender', 'string'],
['Brother', 'brother', 'string', 'Siblings'],
['Sister', 'sister', 'string', 'Siblings']
]
},
function (err, info) {
console.log(err, info)
// Done!
}
)
const xml2csv = require('@wmfs/xml2csv')
xml2csv(
{
xmlPath: 'path/to/file.xml',
csvPath: 'path/to/file.csv',
rootXMLElement: 'Person',
headerMap: [
['Name', 'name', 'string'],
['Age', 'age', 'integer'],
['Gender', 'gender', 'string'],
['Brother', 'brother', 'string', 'Siblings'],
['Sister', 'sister', 'string', 'Siblings']
]
},
)
.then(console.log)
.catch(console.log);
const xml2csv = require('@wmfs/xml2csv')
try {
const res = await xml2csv(
{
xmlPath: 'path/to/file.xml',
csvPath: 'path/to/file.csv',
rootXMLElement: 'Person',
headerMap: [
['Name', 'name', 'string'],
['Age', 'age', 'integer'],
['Gender', 'gender', 'string'],
['Brother', 'brother', 'string', 'Siblings'],
['Sister', 'sister', 'string', 'Siblings']
]
},
)
console.log(res)
} catch(err) {
console.log(err)
}
Input:
<People>
<Person>
<Name>Maggie</Name>
<Age>3</Age>
<Gender>Female</Gender>
<Siblings>
<Brother>Bart</Brother>
<Sister>Lisa</Sister>
</Siblings>
</Person>
<Person>
<Name>Marge</Name>
<Age>45</Age>
<Gender>Female</Gender>
</Person>
</People>
Output:
name, age, gender, brother, sister
"Maggie",3,"Female","Bart","Lisa"
"Marge",45,"Female",,
options
, callback
)Property | Type | Notes |
---|---|---|
xmlPath | string | A path to the xml input file. Cannot be provide with xmlStream property. |
xmlStream | fs.ReadStream | A readable stream from an xml file. Cannot be provide with xmlPath property. |
csvPath | string | The path and filename of the generated CSV output file (note that any intermediate folders will be created). Cannot be provide with csvStream property. |
csvStream | fs.WriteStream | A writeable stream for the generated CSV data. Cannot be provide with csvPath property. |
rootXMLElement | string | The XML root tag for each record, element to split records on in XML file. |
headerMap | [array] | See the Header Map section for more details. |
strict | [boolean] | Should the sax parser run in strict mode ? Defaults to true . |
options.headerMap needs to be in the structure of:
[
[xmlTag, csvHeader, type, parent],
[xmlTag, csvHeader, type, parent],
...
]
$ npm test
FAQs
Convert XML file to CSV file
The npm package @wmfs/xml2csv receives a total of 218 weekly downloads. As such, @wmfs/xml2csv popularity was classified as not popular.
We found that @wmfs/xml2csv demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Cloudflare has launched a setup wizard allowing users to easily create and manage a security.txt file for vulnerability disclosure on their websites.
Security News
The Socket Research team breaks down a malicious npm package targeting the legitimate DOMPurify library. It uses obfuscated code to hide that it is exfiltrating browser and crypto wallet data.
Security News
ENISA’s 2024 report highlights the EU’s top cybersecurity threats, including rising DDoS attacks, ransomware, supply chain vulnerabilities, and weaponized AI.