Reputation: 95
I am trying to create a XML body with js2xmlparser module which looks like this:
<methodCall>
<methodName>Some method name</methodName>
<params>
<param>
<value>
<string>Some value</string>
</value>
<value>
<string>Some value</string>
</value>
</param>
</params>
</methodCall>
my object for parsing:
var obj = {
"methodName": "TsaInfoHandler.getIppCert",
"params": {
"param": [
{value: { string: this.projectPartnerNumber } } ,
{value: { string: this.projectPartnerKey } } ,
]
}
}
but the output I get is:
<?xml version='1.0'?>
<methodCall>
<methodName>Some method name</methodName>
<params>
<param>
<value>
<string>Some value</string>
</value>
</param>
<param>
<value>
<string>Some value</string>
</value>
</param>
</params>
</methodCall>
I just want it so that param
does not repeat after each value
but rather encapsulate all the value
together.
Upvotes: 1
Views: 320
Reputation: 134
What if you make param an object where its key is value as an array?
param: { value: [ { ... }, { ... } ] }
Upvotes: 1