[erlang-questions] How to set the toot tag with xmerl.

Salonee Sinha Roy ssroy1979@REDACTED
Sun Feb 8 20:46:15 CET 2009


Hi All
I have the following erlang code from the xmerl sample in the documentation.

Data =
  {bike,
     [{year,"2003"},{color,"black"},{condition,"new"}],
     [{name,
         [{manufacturer,["Harley Davidsson"]},
          {brandName,["XL1200C"]},
          {additionalName,["Sportster"]}]},
      {engine,
         ["V-engine, 2-cylinders, 1200 cc"]},
      {kind,["custom"]},
      {drive,["belt"]}]}   ,

    NewContent = lists:flatten([Data]),
    RootEl = #xmlElement{content=NewContent},
    Export=xmerl:export_simple([RootEl],xmerl_xml),
    io:format("~p",[lists:flatten(Export)]).

Running this method generates the following xml string

"<?xml version=\"1.0\"?><undefined><bike year=\"2003\" color=\"black\"
condition=\"new\"><name><manufacturer>Harley
Davidsson</manufacturer><brandName>XL1200C</brandName><additionalName>Sportster</additionalName></name><engine>V-engine,
2-cylinders, 1200
cc</engine><kind>custom</kind><drive>belt</drive></bike></undefined>"

The root tag is <undefined>. How do I change this so that the root tag is
"<myxml>"

Thanks
Salonee
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20090208/89525432/attachment.htm>


More information about the erlang-questions mailing list