Can anyone show me how to build a simple XML document using XMERL? The documentation only shows how to append to a current XML document that is read from a file. I want to create a new XML document from scratch.
For example, I want to write a simple structure like this out to an XML file:
Data = {myNode,[{foo,"Foo"},{bar,"Bar"}]}.
Thanks!
xmerl’s “simple” format is similar to yours: (note the third value, a list of child elements)
This can be “exported” into XML to use as a string:
Or written to a file:
Note that export_simple takes a list of elements, not a single root element. Also, depending on what you do with the result, flattening might be unnecessary.