cancel
Showing results for 
Search instead for 
Did you mean: 

Adding multiple elements with XmlHelper

SAPSupport
Employee
Employee
0 Kudos
317

How can you add multiple elements to a node using the XmlHelper?


------------------------------------------------------------------------------------------------------------------------------------------------
Learn more about the SAP Support user and program here.

Accepted Solutions (1)

Accepted Solutions (1)

SAPSupport
Employee
Employee
0 Kudos

You can try to use a loop and within loop build a element/node addition and data filling logic.

Answers (2)

Answers (2)

tomdevilder
Discoverer
0 Kudos

Would be really nice if SAP-CPQ could provide proper example !

tomdevilder
Discoverer
0 Kudos

Hi,

A loop will not be a solution since I need elements with different names, something like below

<users>
<user>
<name>Smith</name>
<firstname>John</firstname>
<country>England</country>
</user>
<user>
<name>Doe</name>
<firstname>Joe</firstname>
<country>U.S.</country>
</user>
</users>

Question is how can you add multiple XMLNodes under a node when these are the only available methods:

- CreateXmlNode(String, Object) Create XML Node with specified node name and node value.
- CreateXmlNode(String, XmlNode[]) Create XML Node with specified node name and node child(ren).
- Load(Stream) Loads XML document for the specified stream.
- Load(String) Loads XML document for the specified text.
- SerializeObject<T> Serializes the specified System.Object and writes the XML document to a System.String.
- SetAttribute Set attribute to specified node

and as far as I understand the one below is the one that I should be able to use, but how can I create "XmlNode[]" an array of XML nodes using your XML helper.

- CreateXmlNode(String, XmlNode[]) Create XML Node with specified node name and node child(ren).

Kind Regards

Tom