Hi!
I am using EzXML trying to make my own custom XML file through julia. I want something that looks like:
<?xml version="1.0" encoding="UTF-8" ?>
<case>
<casedef>
<constantsdef>
<gravity x="0" y="0" z="-9.81" comment="Gravitational acceleration" units_comment="m/s^2" />
<rhop0 value="1000" comment="Reference density of the fluid" units_comment="kg/m^3" />
</constantsdef>
</casedef>
</case>
Then using EzXML and this following code (very coarse code just to get it to work):
using EzXML
doc = parsexml("""
<?xml version="1.0" encoding="UTF-8" ?>
<case>
</case>
""")
rd = root(doc)
constantsdef = addelement!(rd,"constantsdef")
gravity = addelement!(constantsdef,"gravity")
gx = AttributeNode("x","0")
gy = AttributeNode("y","0")
gz = AttributeNode("z","-9.81")
link!(gravity,gx)
link!(gravity,gy)
link!(gravity,gz)
comment=AttributeNode("comment","Gravitational acceleration")
units_comment=AttributeNode("units_comment","m/s^2")
link!(gravity,comment)
link!(gravity,units_comment)
rhop0 = addelement!(constantsdef,"rhop0")
rhop0_value = AttributeNode("value","1000")
link!(rhop0,rhop0_value)
comment=AttributeNode("comment","Reference density of the fluid")
units_comment=AttributeNode("units_comment","kg/m^3")
link!(rhop0,comment)
link!(rhop0,units_comment)
write("Test.xml",doc)
The end result is:
Which is the correct elements, but no type of indentation / new lines are being applied to make it humanreadable too. Could anyone help out?
Thanks, kind regards