simple_xml_load_string and xml attribute types



I am working with an API at the moment, that accepts XML in a request, however the atrributes of that XML have to particular formats (string, int, boolean, dateTime etc). An example of my XML is as follows,



<Property>
<Address>
<AddressLine1>str1234</AddressLine1>
<AddressLine2>str1234</AddressLine2>
<AddressLine3>str1234</AddressLine3>
<AddressLine4>str1234</AddressLine4>
<PostCode>po75xa</PostCode>
<RoyalMailReference>str1234</RoyalMailReference>
</Address>
<PropertyType>DetachedHouse</PropertyType>
<NumberOfBedrooms>3</NumberOfBedrooms>
<YearBuilt>1970</YearBuilt>
</Property>


The XML is stored in a Laravel view that load in like this,



$xml = simplexml_load_string( View::make('samplerequest') );


I then send the request to the API (it is via SOAP), the request I get back shows eve that actually gets sent shows every attribute is a string. How can I define what type each attribute is? Or will will simplexml_load_string() cast everything into a string?


No comments:

Post a Comment