xmltree (util v1.3.5)

View Source

Parse XML into a hierarchical Erlang term

% Example xml:

 <?xml version="1.0" encoding="UTF-8" ?>
 <root id="1">
   <ele id="2"/>
   <ele id="3">vvv\nxxx\n</ele>
 </root>


# Usage example
1> xmltree:file(L).
{root,[{id,<<"1">>}],
     [{ele,[{id,<<"2">>}],[]},
      {ele,[{id,<<"3">>}],<<"vvv\nxxx\n">>}]}

2> Rules = {root, [{id,integer}], [{ele, [{id,integer}], string}]},
2> xmltree:string(L, Rules).
{root,[{id,1}],
   [{ele,[{id,2}],[]},{ele,[{id,3}],"vvv\nxxx\n"}]}

Author: Serge Aleynikov saleyn@gmail.com

Summary

Functions

file(Filename)

file/2

string(XmlS)

string(XmlS, Rules)

xml/1

xml/2