Hey guys.
Say that I am reading an XML file and getting the following information:
k[1:2]
2-element Array{XMLElement,1}:
<floating mkbound="1" mk="12" begin="7206" count="21" property="hard-wood">
<massbody value="2.52" units_comment="kg"/>
<masspart value="0.12" units_comment="kg"/>
<center x="0.2" y="0" z="0.2" units_comment="metres (m)"/>
<inertia units_comment="kg*m^2">
<values v11="0.001632" v12="0" v13="2.60209e-20"/>
<values v21="0" v22="0.003264" v23="0"/>
<values v31="2.60209e-20" v32="0" v33="0.001632"/>
</inertia>
</floating>
<floating mkbound="2" mk="13" begin="7227" count="21" property="hard-wood">
<massbody value="2.52" units_comment="kg"/>
<masspart value="0.12" units_comment="kg"/>
<center x="0.36" y="0" z="0.2" units_comment="metres (m)"/>
<inertia units_comment="kg*m^2">
<values v11="0.001632" v12="0" v13="2.60209e-20"/>
<values v21="0" v22="0.003264" v23="0"/>
<values v31="2.60209e-20" v32="0" v33="0.001632"/>
</inertia>
</floating>
Basically I want to save the data, so I prefer to not use a function but a struct, and I want to make it so that the data is accessed by applying the “mk” property. So for an example I am making a struct like this:
struct Floating
mk
mkbound
beg
cou
property
end
(It is not letting me use “begin” since it is a definition and “count” is a function, don’t know if I can over rule it or if it even makes sense to do so)
Now assigning some random values:
x = Floating(12,1,0,100,"wood")
Floating(12, 1, 0, 100, "wood")
I can now access these fields by simple dot notation, ie. x.mkbound, but I would like to make it in a way where I write:
x(mkbound=12)[beg,cou]
Which means, for the floating with the property mkbound=12, return “begin” and “count” ie. 0 and 100 for this example.
I want to do it this way using a struct, and not a function, since I am using LightXML to read the XML file and would like to free up the memory and save the data in an active Julia editor, for an interactive application.
Kind regards