[Pkg-javascript-commits] [node-expat] 207/371: Added QuickStart usage instructions and API from test.js

Jonas Smedegaard dr at jones.dk
Sun Feb 28 10:00:05 UTC 2016


This is an automated email from the git hooks/post-receive script.

js pushed a commit to branch master
in repository node-expat.

commit 6e54962cc7ad8a5c3189d6c08c1844bb85798d82
Author: AJ ONeal <coolaj86 at gmail.com>
Date:   Tue May 28 23:28:41 2013 -0500

    Added QuickStart usage instructions and API from test.js
---
 README.markdown | 47 +++++++++++++++++++++++++++++++++++++++--------
 1 file changed, 39 insertions(+), 8 deletions(-)

diff --git a/README.markdown b/README.markdown
index 4900f25..ef87caa 100644
--- a/README.markdown
+++ b/README.markdown
@@ -26,14 +26,45 @@ Install node-expat:
 
 Important events emitted by a parser:
 
-- *startElement* with `name, attrs`
-- *endElement* with `name`
-- *text* with `string`
-
-There are more. Use `test.js` for reference.
-
-It's possible to stop and resume the parser from within element handlers using the parsers 
-stop() and resume() methods.
+```javascript
+(function () {
+"use strict";
+
+  var expat = require('./lib/node-expat')
+    , parser
+    ;
+
+  parser = new expat.Parser("UTF-8");
+  parser.on('startElement', function (name, attrs) {
+    console.log(name, attrs);
+  });
+  parser.on('endElement', function (name) {
+    console.log(name);
+  });
+  parser.on('text', function (text) {
+    console.log(text);
+  });
+}());
+
+```
+
+Use `test.js` for reference.
+
+## API ##
+
+- `#on('startElement' function (name, attrs) {})`
+- `#on('endElement' function (name) {})`
+- `#on('text' function (text) {})`
+- `#on('processingInstruction', function (target, data) {})`
+- `#on('comment', function (s) {})`
+- `#on('xmlDecl', function (version, encoding, standalone) {})`
+- `#on('startCdata', function () {})`
+- `#on('startCdata', function () {})`
+- `#on('endCdata', function () {})`
+- `#on('entityDecl', function (entityName, isParameterEntity, value, base, systemId, publicId, notationName) {})`
+- `#on('error', function (e) {})`
+- `#stop()` pauses
+- `#resume()` resumes
 
 ## Error handling ##
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-expat.git



More information about the Pkg-javascript-commits mailing list