duanlie1298 2014-07-11 07:22
浏览 22

simple_xml_load_string和xml属性类型

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?

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 mmocr的训练错误,结果全为0
    • ¥15 python的qt5界面
    • ¥15 无线电能传输系统MATLAB仿真问题
    • ¥50 如何用脚本实现输入法的热键设置
    • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
    • ¥30 深度学习,前后端连接
    • ¥15 孟德尔随机化结果不一致
    • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
    • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
    • ¥15 谁有desed数据集呀