XML/DOM serialization: Difference between revisions

m (→‎{{header|MATLAB}}: Correct header case so example is recognized)
Line 617:
</root>;
var xmlString = xml.toXMLString();</lang>
 
=={{header|Julia}}==
<lang julia>using LightXML
 
# Modified from the documentation for LightXML.jl
 
# create an empty XML document
xdoc = XMLDocument()
 
# create & attach a root node
xroot = create_root(xdoc, "States")
 
# create the first child
xs1 = new_child(xroot, "State")
 
# add the inner content
add_text(xs1, "Massachusetts")
 
# set attribute
set_attribute(xs1, "tag", "MA")
 
# likewise for the second child
xs2 = new_child(xroot, "State")
add_text(xs2, "Illinois")
# set multiple attributes using a dict
set_attributes(xs2, Dict("tag"=>"IL", "cap"=>"Springfield"))
 
# now, the third child
xs3 = new_child(xroot, "State")
add_text(xs3, "California")
# set attributes using keyword arguments
set_attributes(xs3; tag="CA", cap="Sacramento")
 
println(xdoc)
</lang>{{output}}<pre>
<?xml version="1.0" encoding="utf-8"?>
<States>
<State tag="MA">Massachusetts</State>
<State tag="IL" cap="Springfield">Illinois</State>
<State tag="CA" cap="Sacramento">California</State>
</States>
</pre>
 
 
=={{header|Kotlin}}==
4,105

edits