Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jonnay/jxml
Represent XML (and HTML) as JSON
https://github.com/jonnay/jxml
Last synced: about 7 hours ago
JSON representation
Represent XML (and HTML) as JSON
- Host: GitHub
- URL: https://github.com/jonnay/jxml
- Owner: jonnay
- Created: 2011-05-06T06:26:34.000Z (over 13 years ago)
- Default Branch: master
- Last Pushed: 2011-05-08T03:57:38.000Z (over 13 years ago)
- Last Synced: 2024-11-21T12:48:39.820Z (2 months ago)
- Language: JavaScript
- Homepage:
- Size: 89.8 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.org
Awesome Lists containing this project
README
* jxml
Represent XML as a simple Javascript datatype. This is very similar to SXML (http://en.wikipedia.org/wiki/SXML)
Because jxml is simply an array, it is theoretically very easy to do some really cool things with it like:
- write very simple xpath like parsers
- write a simple, yet powerful, templating engine
- write xslt style transformations using json and javascriptIn fact, maybe these features will make it into jxml soon. But for now it is super basic.
** Getting Started
This depends on Valentine, cause Valentine is kinda cool.
https://github.com/ded/valentineThe dependency is kinda weak though. You could easily remove it if you wanted.
Right now only one function is exported: render.
Quite simply you have an array that represents your xml, and use render to actually transform it into xml.
#+BEGIN_EXAMPLE
var j = require('jxml');
jxml.render(["html",
["head", ["title", "REPL"]],
["body",
"",
["form", {"action": "/", "method":"POST"},
"Fear the form",
["input", {"type": "text", "name":"command"}],
"With improper embedded stuff",
["input", {"type": "submit", "name":"submit"}]]]]);
#+END_EXAMPLEThis would emit:
#+BEGIN_SRC
REPL
Fear the form
With improper embedded stuff
#+END_SRC(actually, it won't have any CRs or indenting... and you'll need to do something with the value that is returned... but you knew that.)
** Upcoming...
*** TODO there should be a jxml function, that takes xml and turns it into json
*** TODO implement a simple xpath query function
*** TODO allow the handling of functions inside of jxml for better templatey goodness and code-as-data-fun
*** TODO better PI handling
*** TODO namespaces a-la SXML?
*** TODO There might be some dom-goodness to explore here