All Projects → processone → Fast_xml

processone / Fast_xml

Licence: apache-2.0
Fast Expat based Erlang XML parsing library

Programming Languages

elixir
2628 projects
erlang
1774 projects

Labels

Projects that are alternatives of or similar to Fast xml

Dino
Modern XMPP ("Jabber") Chat Client using GTK+/Vala
Stars: ✭ 1,637 (+1553.54%)
Mutual labels:  xml, xmpp
Laravel Sitemap
Create and generate sitemaps with ease
Stars: ✭ 1,325 (+1238.38%)
Mutual labels:  xml
Dbwebapi
(Migrated from CodePlex) DbWebApi is a .Net library that implement an entirely generic Web API (RESTful) for HTTP clients to call database (Oracle & SQL Server) stored procedures or functions in a managed way out-of-the-box without any configuration or coding.
Stars: ✭ 84 (-15.15%)
Mutual labels:  xml
Phpgpx
Simple library for reading and creating GPX files written in PHP.
Stars: ✭ 92 (-7.07%)
Mutual labels:  xml
Beagle Im
XMPP client for macOS based on TigaseSwift XMPP library
Stars: ✭ 86 (-13.13%)
Mutual labels:  xmpp
Metayaml
A powerful schema validator!
Stars: ✭ 92 (-7.07%)
Mutual labels:  xml
Ofbiz Plugins
Apache OFBiz is an open source product for the automation of enterprise processes. It includes framework components and business applications for ERP, CRM, E-Business/E-Commerce, Supply Chain Management and Manufacturing Resource Planning. OFBiz provides a foundation and starting point for reliable, secure and scalable enterprise solutions.
Stars: ✭ 83 (-16.16%)
Mutual labels:  xml
Datingapp
Dating UI kit is used for online meet up with girls and boys . The screen contains more than 30 icons and most of all required elements required to design an application like this. The XML and JAVA files contains comments at each and every point for easy understanding. Everything was made with a detail oriented style and followed by today's web trends. Clean coded & Layers are well-organized, carefully named, and grouped.
Stars: ✭ 97 (-2.02%)
Mutual labels:  xml
Kanvas
Make canvas easier to use in Kotlin 😊
Stars: ✭ 93 (-6.06%)
Mutual labels:  xml
Filecontextcore
FileContextCore is a "Database"-Provider for Entity Framework Core and adds the ability to store information in files instead of being limited to databases.
Stars: ✭ 91 (-8.08%)
Mutual labels:  xml
Xmlmapper
A simple way to map XML to Objects written in Swift
Stars: ✭ 90 (-9.09%)
Mutual labels:  xml
Xmlsec
XML Security Library
Stars: ✭ 88 (-11.11%)
Mutual labels:  xml
Interfacss
The CSS-inspired styling and layout framework for iOS
Stars: ✭ 92 (-7.07%)
Mutual labels:  xml
Jcabi Xml
Java XML Parsing, Transforming, Printing, and Validating
Stars: ✭ 85 (-14.14%)
Mutual labels:  xml
Soupsieve
A modern CSS selector implementation for BeautifulSoup
Stars: ✭ 95 (-4.04%)
Mutual labels:  xml
Hale
(Spatial) data harmonisation with hale studio (formerly HUMBOLDT Alignment Editor)
Stars: ✭ 84 (-15.15%)
Mutual labels:  xml
Sax Wasm
The first streamable, fixed memory XML, HTML, and JSX parser for WebAssembly.
Stars: ✭ 89 (-10.1%)
Mutual labels:  xml
Candy
JavaScript-based multi-user chat client for XMPP.
Stars: ✭ 1,316 (+1229.29%)
Mutual labels:  xmpp
Crawlerpack
Java 網路資料爬蟲包
Stars: ✭ 99 (+0%)
Mutual labels:  xml
Quickblox Javascript Sdk
JavaScript SDK of QuickBlox cloud backend platform
Stars: ✭ 98 (-1.01%)
Mutual labels:  xmpp

Erlang and Elixir XML Parsing

Build Status Coverage Status Hex version

Fast Expat based Erlang XML parsing and manipulation library, with a strong focus on XML stream parsing from network.

It supports:

  • Full XML structure parsing: Suitable for small but complete XML chunks.
  • XML stream parsing: Suitable for large XML document, or infinite network XML stream like XMPP.

This module can parse files much faster than built-in module xmerl. Depending on file complexity and size fxml_stream:parse_element/1 can be 8-18 times faster than calling xmerl_scan:string/2.

This application was previously called p1_xml and was renamed after major optimisations to put emphasis on the fact it is damn fast.

Building

Erlang XML parser can be build as follow:

./configure && make

Erlang XML parser is a rebar-compatible OTP application. Alternatively, you can build it with rebar:

rebar compile

Dependencies

Erlang XML parser depends on Expat XML parser. You need development headers for Expat library to build it.

You can use configure options to pass custom path to Expat libraries and headers:

--with-expat=[ARG]      use Expat XML Parser from given prefix (ARG=path);
                        check standard prefixes (ARG=yes); disable (ARG=no)
--with-expat-inc=[DIR]  path to Expat XML Parser headers
--with-expat-lib=[ARG]  link options for Expat XML Parser libraries

xmlel record and types

XML elements are provided as Erlang xmlel records.

Format of the record allows defining a simple tree-like structure. xmlel record has the following fields:

  • name :: binary()
  • attrs :: [attr()]
  • children :: [xmlel() | cdata()]

cdata type is a tuple of the form:

{xmlcdata, CData::binary()}

attr type if a tuple of the form:

{Name::binary(), Value::binary()}

XML full structure parsing

You can definitely parse a complete XML structure with fast_xml:

$ erl -pa ebin
Erlang/OTP 17 [erts-6.3] [source] [64-bit] [smp:4:4] [async-threads:10] [hipe] [kernel-poll:false] [dtrace]

Eshell V6.3  (abort with ^G)
1> application:start(fast_xml).
ok
2> rr(fxml).
[xmlel]
3> fxml_stream:parse_element(<<"<test>content cdata</test>">>).
#xmlel{name = <<"test">>,attrs = [],
       children = [{xmlcdata,<<"content cdata">>}]}

XML Stream parsing example

You can also parse continuous stream. Our design allows decoupling very easily the process receiving the raw XML to parse from the process receiving the parsed content.

The workflow is as follow:

state = new(CallbackPID); parse(state, data); parse(state, moredata); ...

and the parsed XML fragments (stanzas) are send to CallbackPID.

With that approach you can be very flexible on how you architect your own application.

Here is an example XML stream parsing:

$ erl -pa ebin
Erlang/OTP 17 [erts-6.3] [source] [64-bit] [smp:4:4] [async-threads:10] [hipe] [kernel-poll:false] [dtrace]

Eshell V6.3  (abort with ^G)

% Start the application:
1> application:start(fast_xml).
ok

% Create a new stream, using self PID to received XML parsing event:
2> S1 = fxml_stream:new(self()).
<<>>

% Start feeding content to the XML parser.
3> S2 = fxml_stream:parse(S1, <<"<root>">>).
<<>>

% Receive Erlang message send to shell process:
4> flush().
Shell got {'$gen_event',{xmlstreamstart,<<"root">>,[]}}
ok

% Feed more content:
5> S3 = fxml_stream:parse(S2, <<"<xmlelement>content cdata</xmlelement>">>).
<<>>

% Receive more messages:
6> flush().
Shell got {'$gen_event',
              {xmlstreamelement,
                  {xmlel,<<"xmlelement">>,[],
                      [{xmlcdata,<<"content cdata">>}]}}}
ok

% Feed more content:
7> S4 = fxml_stream:parse(S3, <<"</root>">>).      
<<>>

% Receive messages:
8> flush().
Shell got {'$gen_event',{xmlstreamend,<<"root">>}}
ok

9> fxml_stream:close(S4).
true

Note how the root element is important. We expect to have the root element serve as boundary with stream start and stream end event. Then, lower level tags are passed as sub stream elements.

How does this module relate to exmpp ?

This module is a low level fast XML parser. It is not an XMPP client library like exmpp.

References

This module is use at large scale for parsing massive XML content in ejabberd XMPP server project. It is used in production in thousands of real life deployments.

Development

Test

Unit test

You can run eunit test with the command:

$ rebar eunit

Elixir / Quickcheck test

You can run test written with Elixir / Quickcheck thanks to the mix command:

MIX_EXS=test/elixir/mix.exs mix test
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].