Code Monkey home page Code Monkey logo

nml-parser's Introduction

nml

Namespace Markup Language parser

##How to set up To parse a document, you have to create new nml object.

var doc = new nml();

Then, you can change to failonerr mode, that stops the parser if an error occures.

doc.failonerr = true;

And finally you should set up sandbox elements - that ones, which may contain only one text child (such as html:script element in html6) TODO

doc.sandbox = [
 {name:"script",space:"html"},
 {name:"textarea",space:"form"},
 {name:"customelementsrock"}
];

Now you are ready to parse.

##How to parse Before the parsing, you have to load your document (via http or from a local file) into a local variable (as a string), then you can call the parse function.

var str = "<svg:svg width=100 height=100><g><svg:path d=\"M0,0 L100,100\" /></g></svg:svg>";
doc.parse(str);
console.log(doc.childs[0]);

You can also call the parser asynchronously. TODO

doc.parse.on("error",function(e){
 console.log(e.line);
 console.log(e.collumn);
 console.log(e.message);
});
doc.parse.on("success",function(e){
 console.log(doc.[0]);
});
doc.parse(str,true);

After parsing you will maybe need to export a DOM document. That can be easily done using the toDOM function. TODO

doc.parse(str);
node = doc.toDOM().body;
document.importNode(node,true);

nml-parser's People

Contributors

m93a avatar

Watchers

James Cloos avatar  avatar

Forkers

seraph-b

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.