![From Academia to Industry](https://cdn.sanity.io/images/cgdhsj6q/production/70501690bf807891573e259da9719cf24302c7e3-4288x2848.jpg?w=400&fit=max&auto=format)
Employee Spotlight
From Academia to Industry
Philipp Burckhardt recounts his journey from childhood computer fascinations, to building an e-learning platform at Carnegie Mellon University, and on to his current role at Socket.
moddle-xml
Advanced tools
Changelog
10.1.0
FEAT
: generate sourcemapsReadme
Read and write XML documents described with moddle.
Get the libray via npm
npm install --save moddle-xml
Create a moddle instance
import Moddle from 'moddle';
import {
Reader,
Writer
} from 'moddle-xml';
const model = new Moddle([ myPackage ]);
Use the reader to parse XML into an easily accessible object tree:
const model; // previously created
const xml =
'<my:root xmlns:props="http://mypackage">' +
'<my:car id="Car_1">' +
'<my:engine power="121" fuelConsumption="10" />' +
'</my:car>' +
'</my:root>';
const reader = new Reader(model);
const rootHandler = reader.handler('my:Root');
// when
try {
const {
rootElement: cars,
warnings
} = await reader.fromXML(xml, rootHandler);
if (warnings.length) {
console.log('import warnings', warnings);
}
console.log(cars);
// {
// $type: 'my:Root',
// cars: [
// {
// $type: 'my:Car',
// id: 'Car_1',
// engine: [
// { $type: 'my:Engine', powser: 121, fuelConsumption: 10 }
// ]
// }
// ]
// }
} catch (err) {
console.log('import error', err, err.warnings);
}
Use the writer to serialize the object tree back to XML:
var model; // previously created
var cars = model.create('my:Root');
cars.get('cars').push(model.create('my:Car', { power: 10 }));
var options = { format: false, preamble: false };
var writer = new Writer(options);
var xml = writer.toXML(bar);
console.log(xml); // <my:root xmlns:props="http://mypackage"> ... <my:car power="10" /></my:root>
MIT
FAQs
XML import/export for documents described with moddle
The npm package moddle-xml receives a total of 65,995 weekly downloads. As such, moddle-xml popularity was classified as popular.
We found that moddle-xml demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 8 open source maintainers 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.
Employee Spotlight
Philipp Burckhardt recounts his journey from childhood computer fascinations, to building an e-learning platform at Carnegie Mellon University, and on to his current role at Socket.
Security News
Git dependencies in open source packages can introduce significant risks, including lack of version control, stability issues, dependency drift, and difficulty in auditing, making them potential targets for supply chain attacks.
Security News
Node.js has added experimental support for TypeScript, a move that highlights the growing importance of TypeScript in modern development.