Good day! I work with one service through soap wsdl. Everything goes smoothly, but when I send some data, I need every parameter in the data that receives a NULL value to be passed through the xsi attribute: nil = 'true' and I don’t know how to do it. Simply put, I need the record to be like this:

<area_common_property xsi:nil="true"/> 

And she is:

 <area_common_property >NULL</area_common_property> 

How to add an attribute xsi: nil = 'true' to an element in SOAP?

  • Where is the code for the formation of the request? - Naumov
  • You should already have a namespace in your xml. How? - splash58 2:19 pm

1 answer 1

You can do this:

 $xml = new SimpleXMLElement("<root></root>"); $xml->addChild('area_common_property')->addAttribute("xsi:nil", "true", "http://www.w3.org/2001/XMLSchema-instance"); echo $xml->asXml(); 

Conclusion:

 <?xml version="1.0"?> <root> <area_common_property xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/> </root> 
  • <area_common_property nil="true"/> and I want xsi:nil - splash58
  • one
    @ splash58 added - you need to specify another namespace - Alexey Shmelyov
  • Most likely it is already spelled out, you can simply refer to it, so as not to declare this element - splash58