goorj goorj - 7 months ago 100
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?


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>