Skip to content

Essentials for schema-driven, type-safe XML processing

Notifications You must be signed in to change notification settings

ieay4a/xsd-tools

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

xsd tools logo

xsd-tools

Essentials for schema-driven, type-safe XML processing

Example

Check out /example for a working example.

# install the generator and dependencies
yarn add xsd-tools xmldom
yarn add -D @xsd-tools/typescript
# generate types and parser based on xml schema
yarn run xsd-ts example/greeting.xsd example/greeting.ts
// feed xml dom into parser to get the typed valid object structure
import { readFileSync } from 'fs';
import { DOMParser } from '@xmldom/xmldom';
import parse from './greeting.ts';

const xml = readFileSync('example/greeting.xml', 'utf8');

const dom = new DOMParser().parseFromString(xml, 'text/xml');

const { greeting } = parse(dom);

console.log(`${greeting['@from']}: ${greeting['#']}`);

License

MIT

About

Essentials for schema-driven, type-safe XML processing

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 97.6%
  • JavaScript 2.4%