Skip to content

Commit

Permalink
Updated README to reflect the current API.
Browse files Browse the repository at this point in the history
  • Loading branch information
jkingsbery committed Mar 30, 2014
1 parent 1dce9a0 commit 9507732
Showing 1 changed file with 24 additions and 10 deletions.
34 changes: 24 additions & 10 deletions README.md
Expand Up @@ -9,8 +9,8 @@ and doing some basic XML structures manipulation.
Building
========

**exml** is rebar-compatible OTP application, run *make* or
*./rebar compile* in order to build it.
**exml** is a rebar-compatible OTP application, run `make` or
`./rebar compile` in order to build it.

As a requirement, development headers for expat library are
required.
Expand All @@ -21,13 +21,27 @@ Using
**exml** can parse both XML streams as well as single XML
documents at once.

At first, new parser instance must be created:
<pre>
{ok, Parser} = exml:new_parser().
</pre>
To parse a whole XML Document:

Then, one must feed parser with XML document:
<pre>
ok = exml:parse(Parser, <<"<my_xml_doc/>">>, 1).
</pre>
```erlang
{ok, Parser} = exml:parse(<<"<my_xml_doc/>">>).
```

To generate an XML document from Erlang terms:

```erlang
Xml = {xmlel,<<"foo">>,
[{<<"attr1">>,<<"bar">>}], % Attributes
[{xmlcdata,"Some Value"}] %Elements
}.
exml:to_list(Xml).
```

Which results in
```
<foo attr1='bar'>Some Value</foo>
```

```exml:to_binary/1``` works similarly.

For an example of using the streaming API, so test/exml_stream_tests.erl

0 comments on commit 9507732

Please sign in to comment.