Respected Contributor.. relent0r Respected Contributor..
Respected Contributor..
463 views

Edit XML operation, can you update multiple elements.

I'll preface this by saying I haven't done xml editing before.

I'm trying to use the 'edit xml' operation to update an xml that it pulled from vcloud vdc configuration. Plan was to query the vdc config, take the resulting xml, edit what needs editing then performing a put with the resulting edited xml.

I'm using the xpath to get to the memory configuration and find that in the resulting XML I only get the element that I updated but I have mandatory elements that are required.

example.

<ComputeCapacity>
  <Cpu>
        <Units>MHz</Units>
        <Allocated>0</Allocated>
        <Limit>25000</Limit>
        <Reserved>0</Reserved>
        <Used>0</Used>
        <Overhead>0</Overhead>
  </Cpu>
  <Memory>
       <Units>MB</Units>
       <Allocated>0</Allocated>
       <Limit>102400</Limit>
       <Reserved>0</Reserved>
       <Used>0</Used>
       <Overhead>0</Overhead>
  </Memory>
</ComputeCapacity>

So I set the xpath to Memory, then update say the <Limit> element. The resulting xml has no other elements from that xpath except <Limit>.

I don't see anything obvious in the documentation, is there a way to edit multiple elements in this path or not remove the existing ones. I was hoping I could just put all elements into the value input but don't see a delimeter that works.

Whats the best way to achieve updating multiple elements or not truncating the other ones?

Labels (1)
0 Likes
1 Reply
scuda20 Super Contributor.
Super Contributor.

Re: Edit XML operation, can you update multiple elements.

This may not be the best way but it works for me. I read my xml into a var and then edit each element or attribute in a separate "Edit XML" operation like the screen shot. On each operation the results are overwritten so that the next "Edit XML" has the updated. My XML skills are newbie to intermediate so I am sure there are more advanced ways to do this in file but this works just using the operations in studio.

When you use the "Edit XML" to write it back out, it puts it in an interesting format visually so be aware but it's still XML compliant.

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.