@@ -154,6 +154,21 @@ A callback module can inherit definitions from other callback modules, through
154154the required function ` '#xml-interitance#'() -> [ModuleName::atom()] ` .
155155
156156_ See also:_ ` export/2 ` , ` export_simple/3 ` .
157+
158+ ## Examples
159+
160+ ``` erlang
161+ 1 > {Element , []} = xmerl_scan :string (" <greeting>hello</greeting>" ).
162+ 2 > lists :flatten (xmerl :export ([Element ], xmerl_xml , [])).
163+ " <?xml version=\" 1.0\" ?><greeting>hello</greeting>"
164+ ```
165+
166+ ``` erlang
167+ 1 > {Element , []} = xmerl_scan :string (" <note><to>Tove</to><from>Jani</from></note>" ).
168+ 2 > Prolog = [" <?xml version=\" 1.0\" encoding=\" UTF-8\" ?>\n " ].
169+ 3 > lists :flatten (xmerl :export ([Element ], xmerl_xml , [{prolog , Prolog }])).
170+ " <?xml version=\" 1.0\" encoding=\" UTF-8\" ?>\n <note><to>Tove</to><from>Jani</from></note>"
171+ ```
157172""" .
158173-spec export (Content , Callback , RootAttributes ) ->
159174 ExportedFormat :: term () when
@@ -214,6 +229,13 @@ attributes. The XML-data is always converted to normal form before being passed
214229to the callback module.
215230
216231_ See also:_ ` export/3 ` , ` export_simple/2 ` .
232+
233+ ## Examples
234+
235+ ``` erlang
236+ 1 > lists :flatten (xmerl :export_simple ([{greeting , [], [" hello" ]}], xmerl_xml , [])).
237+ " <?xml version=\" 1.0\" ?><greeting>hello</greeting>"
238+ ```
217239""" .
218240-spec export_simple (Content , Callback , RootAttributes ) ->
219241 ExportedFormat :: term () when
@@ -242,7 +264,16 @@ export1(Content, Callbacks, RootAttrs) when is_list(Content) ->
242264 tagdef ('#root#' ,1 ,[],Args ,Callbacks ).
243265
244266
245- -doc " Exports simple XML content directly, without further context." .
267+ -doc """
268+ Exports simple XML content directly, without further context.
269+
270+ ## Examples
271+
272+ ``` erlang
273+ 1 > lists :flatten (xmerl :export_simple_content ([{greeting , [], [" hello" ]}], xmerl_xml )).
274+ " <greeting>hello</greeting>"
275+ ```
276+ """ .
246277-spec export_simple_content (Content , Callback ) -> _ when
247278 Content :: [simple_element ()],
248279 Callback :: callback ().
@@ -255,6 +286,14 @@ export_simple_content(Content, Callbacks) when is_list(Callbacks) ->
255286
256287-doc """
257288Export normal XML content directly, without further context.
289+
290+ ## Examples
291+
292+ ``` erlang
293+ 1 > {Element , []} = xmerl_scan :string (" <greeting>hello</greeting>" ).
294+ 2 > lists :flatten (xmerl :export_content ([Element ], [xmerl_xml ])).
295+ " <greeting>hello</greeting>"
296+ ```
258297""" .
259298-spec export_content (Content , Callbacks ) -> _ when
260299 Content :: [element ()],
@@ -274,7 +313,16 @@ export_content([E | Es], Callbacks) ->
274313export_content ([], _Callbacks ) ->
275314 [].
276315
277- -doc " Export a simple XML element directly, without further context." .
316+ -doc """
317+ Export a simple XML element directly, without further context.
318+
319+ ## Examples
320+
321+ ``` erlang
322+ 1 > lists :flatten (xmerl :export_simple_element ({greeting , [], [" hello" ]}, xmerl_xml )).
323+ " <greeting>hello</greeting>"
324+ ```
325+ """ .
278326-spec export_simple_element (Element , Callback ) -> _ when
279327 Element :: simple_element (),
280328 Callback :: callback ().
@@ -284,7 +332,17 @@ export_simple_element(Element, Callback) when is_atom(Callback) ->
284332export_simple_element (Element , Callbacks ) when is_list (Callbacks ) ->
285333 export_element (xmerl_lib :expand_element (Element ), Callbacks ).
286334
287- -doc " Exports a normal XML element directly, without further context." .
335+ -doc """
336+ Exports a normal XML element directly, without further context.
337+
338+ ## Examples
339+
340+ ``` erlang
341+ 1 > {Element , []} = xmerl_scan :string (" <greeting>hello</greeting>" ).
342+ 2 > lists :flatten (xmerl :export_element (Element , xmerl_xml )).
343+ " <greeting>hello</greeting>"
344+ ```
345+ """ .
288346-spec export_element (Element , Callback ) -> _ when
289347 Element :: element (),
290348 Callback :: callback ().
@@ -312,6 +370,14 @@ export_element(#xmlDecl{}, _CBs) ->
312370
313371-doc """
314372For on-the-fly exporting during parsing (SAX style) of the XML document.
373+
374+ ## Examples
375+
376+ ``` erlang
377+ 1 > {Element , []} = xmerl_scan :string (" <empty/>" ).
378+ 2 > lists :flatten (xmerl :export_element (Element , xmerl_xml , state0 )).
379+ " <empty/>"
380+ ```
315381""" .
316382-spec export_element (Element , Callback , CallbackState ) ->
317383 ExportedFormat when
@@ -355,7 +421,16 @@ tagdef(Tag,Pos,Parents,Args,CBs) ->
355421 end .
356422
357423
358- -doc " Find the list of inherited callback modules for a given module." .
424+ -doc """
425+ Find the list of inherited callback modules for a given module.
426+
427+ ## Examples
428+
429+ ``` erlang
430+ 1 > xmerl :callbacks (xmerl_xml ).
431+ [xmerl_xml ]
432+ ```
433+ """ .
359434-spec callbacks (Module :: module ()) -> [module ()].
360435callbacks (Module ) ->
361436 Result = check_inheritance (Module , []),
0 commit comments