PHP nusoap how to remove array wrapper element from response

538 Views Asked by At

I am using PHP nusoap library to create a webservice. The service returns 2 fields and an array of users and soap body is formatted as below:

<company></company>
<noOfUsers></noOfUsers>
<users>
    <user>
      .......
    </user>
    <user>
      .......
    </user>
    <user>
      .......
    </user>
</users>

How can i change this response to remove the users wrapper so that the response looks like:

<company></company>
<noOfUsers></noOfUsers>
<user>
.......
</user>
<user>
.......
</user>
<user>
.......
</user>
1

There are 1 best solutions below

0
On

TL;DR: you can’t

This is impossible because valid XML document can not have top-level nodes with same names. I bet there should be kinda hack/workaround, but I woul suggest you not to enter this territory and deal with what’s being generated by default.