44 lines
1.1 KiB
JavaScript
44 lines
1.1 KiB
JavaScript
const { create } = require('xmlbuilder2');
|
|
const fs = require('fs');
|
|
|
|
let file_name = 'hacon-him-search-api-agency-filter';
|
|
console.log('file_name: ' + file_name);
|
|
|
|
const ns = 'http://vbn.de/hacon/him/search/api/agency-filter';
|
|
console.log('ns: ' + ns);
|
|
|
|
const root = create(
|
|
{
|
|
version: '1.0',
|
|
encoding: "UTF-8",
|
|
standalone: "yes"
|
|
}
|
|
)
|
|
.ele('flt:filter')
|
|
.att('xmlns', ns)
|
|
.ele('flt:line')
|
|
.att('name', 'Bus 58')
|
|
.att('operatorCode', 'BSA')
|
|
.att('operator', 'Bremer Straßenbahn AG')
|
|
.att('dlid', 'de:VBN:58')
|
|
.up()
|
|
.ele('flt:line')
|
|
.att('name', 'Bus 104')
|
|
.att('operatorCode', 'BSA')
|
|
.att('operator', 'Bremer Straßenbahn AG')
|
|
.att('dlid', 'de:VBN:104')
|
|
.up();
|
|
|
|
//end: convert xml document to its string representation
|
|
const xml = root.end({ prettyPrint: true });
|
|
console.log('xml: ' + xml);
|
|
|
|
let full_file_name = "./" + file_name + ".xml";
|
|
console.log('full_file_name: ' + full_file_name);
|
|
|
|
fs.writeFileSync(full_file_name, xml, function(err) {
|
|
if (err) throw err;
|
|
});
|
|
|
|
//FYI: https://stackoverflow.com/a/38829931/15078958
|