I am editing an existing XML file. I cannot edit an element (the element “range”) that is a multiple value element (a list or an array?), as shown in the XML code below.
<objects>
<PinJoint name="revolute">
<socket_parent_frame>torso_offset</socket_parent_frame>
<socket_child_frame>base_offset</socket_child_frame>
<coordinates>
<Coordinate name="revolute_angle">
<default_value>0</default_value>
<default_speed_value>0</default_speed_value>
<range>-1.5700000000000001 1.5700000000000001</range>
<clamped>true</clamped>
<locked>true</locked>
</Coordinate>
</coordinates>
I want to rewrite the values of the element “range”. In this case, these are two numeric values (doubles) separated by spaces.
I am trying to do this with the following c# code
XDocument xdoc = XDocument.Load(@"G:/My Drive/File.xml");
double r1 = new double[,] { {0.1745, 1.3963 } };
var pinjoints = xdoc.Root.Descendants("objects").Elements("PinJoint").Descendants("coordinates").Elements("Coordinate").FirstOrDefault(x => x.Attribute("name").Value == "revolute_angle");
pinjoints.SetElementValue("range", r1);
but the “range” element is rewritten as follow:
<range>System.Double[,]</range>
Can you please help me to edit the element “range” by rewriting one or all its numeric values?
Best regards
Andrés