goorj goorj - 1 year ago 264
PHP Question

How to add attributes to soapVars

I'd like to create soapVars with attributes like this:

<tag attr="xxx">yyy</tag>

Is this possible with the SoapVar constructor, but without using XSD_ANYXML and raw xml strings?

Answer Source

The best way to do it is:

 $tag['_'] = 'yyy'; 
 $tag['attr'] = 'xxx'; 
 $tagVar = new SoapVar($tag, SOAP_ENC_OBJECT); 


the result would be:

<tag attr="xxx">yyy</tag>
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download