diff --git a/README.md b/README.md index 3166cdb..a80d13d 100644 --- a/README.md +++ b/README.md @@ -186,7 +186,7 @@ ## Modules NPM -### xml-mapping +### xml-mapping Module NPM de transformation XML <-> JSON ([README du module](https://github.com/Inist-CNRS/node-xml-mapping)) @@ -195,3 +195,38 @@ Module NPM de recherche dans un document XML parsé en DOM ([README du module](https://github.com/goto100/xpath)) + +### node-expat + +Module NPM permettant de parcourir un document via une API SAX. + +Documentation : http://node-xmpp.org/doc/expat.html + +Ci-après un exemple un peu plus complexe qui transforme un fichier XML vers un syntaxe "JSON-like". + +XML à traiter : + +```xml + + + Outils XML ISTEX + + + + + Niederlender + Claude + + + Caron + Étienne + + + +``` + +appel du [accès au script lui-même](https://git.istex.fr/istex/ade-outils-xml/blob/master/tools/sax-parser-sample.js) : + +```bash +tools/sax-parser-sample.js xml/minimal.xml +``` diff --git a/tools/sax-parser-sample.js b/tools/sax-parser-sample.js index efdcc2c..9ea45dc 100755 --- a/tools/sax-parser-sample.js +++ b/tools/sax-parser-sample.js @@ -38,12 +38,12 @@ parser.on('text', function(txt) { //affichage des noeuds texte non vide if (txt.trim() !== "") { - console.log(indentation() + "text : \"" + txt + "\"") ; + console.log(indentation() + "texte : \"" + txt + "\"") ; } }); // Évément déclenché sur commentaire -parser.on('comment', function(txt) { +parser.on('commentaire', function(txt) { //affichage des commentaires console.log(indentation() + "comment : \"" + txt + "\""); });