I have the following XML structure (simplified version):
<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="LMSDacSolutionReport.xsl" ?>
<LMS>
<DurabilityTaskDefinition>
<Material IdRef="Material_AlSi9Cu3" />
<Tasks>
<Task>
<Material IdRef="AlSi9Cu3">
<Parameter Name="Temperature" Value="293.15"/>
</Material>
</Task>
</Tasks>
</DurabilityTaskDefinition>
<Material>
<Node>
<Parameter Name="Temperature" Value="293.15"/>
<Parameter Name="SigMeanHat" Value="0"/>
<Parameter Name="R_Ratio" Value="-1"/>
</Node>
</Material>
</LMS>
I need to change the value of the Parameter Temperature to 300 (Material - Node - Parameter('Temperature')(Line 16).
The problem is that I have the tag <Material>
2 times before that, and this position will vary each time I run the code. I want to tell MATLAB to change the value of the Parameter with attribute: Name 'Temperature', only if the Material tag is on the second level after <LMS>
, or if the material tag is after the end of the tag: 'DurabilityTaskDefinition' .
So far I am sure just how to open and read the file:
xDoc = xmlread('C:\TEST\Durability Strain Life Analysis Solution.12.xml');
allListItems=xDoc.getElementsByTagName('Material');
Material=allListItems.item(2);
...
xmlwrite('test2.xml',xDoc);