I have an xml file.
<?xml version='1.0' encoding='utf-8'?>
<systemdata>
<process>
<number code="hsfg" class="hgdgf" tool="gagfa">
<value type="string" />
<value type="None" />
</number>
<!-- ID -->
<id code="hsfg" class="gfdg" tool="fadg">
<value type="string" />
<value type="None" />
</id>
</process>
</systemdata>
I would like to append this array to my XML file above.
memorys = []
for mem in wmiquery.Win32_PhysicalMemory():
sysmem = {}
sysmem['location'] = mem.DeviceLocator
sysmem['banklabel'] = mem.BankLabel
sysmem['cap'] = mem.Capacity
memorys.append(sysmem)
for m in memorys:
print(m)
The value of m is like this:
{'location': 'DIMM1', 'banklabel': 'ChannelA', 'cap': '8589934592'}
{'location': 'DIMM2', 'banklabel': 'ChannelA', 'cap': '8589934592'}
I would like to append these array to my XML. So my expectation based on the array above, I will append 2 new element. If the array has 4 then create new 4 element. Here is my expectation output:
<?xml version='1.0' encoding='utf-8'?>
<systemdata>
<process>
<number code="hsfg" class="hgdgf" tool="gagfa">
<value type="string" />
<value type="None" />
</number>
<!-- ID -->
<id code="hsfg" class="gfdg" tool="fadg">
<value type="string" />
<value type="None" />
</id>
</process>
<!-- memory -->
<unitmemory>
<!-- data -->
<module location="DIMM1">
<banklabel tool="banklabel">
<value type="string">ChannelA</value>
</banklabel>
<cap tool="cap">
<value type="string">8589934592</value>
</cap>
</module>
<module location="DIMM2">
<banklabel tool="banklabel">
<value type="string">ChannelA</value>
</banklabel>
<cap tool="cap">
<value type="string">8589934592</value>
</cap>
</module>
</unitmemory>
</systemdata>
Anyone can give me any idea?