Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

pocketbitcoin/xsd-tools

Open more actions menu

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 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';
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

Packages

No packages published
Morty Proxy This is a proxified and sanitized view of the page, visit original site.