簡體   English   中英

使用simplexml_load_string轉換具有多個名稱空間的xml?

[英]Using simplexml_load_string to convert xml with multiple name spaces?

我將如何使用simplexml_load_string()將xml的以下位轉換為可用的php對象?

<soapenv:envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<env:header xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <soapenv:body>
        <v10:ratereply xmlns:v10="http://fedex.com/ws/rate/v10">
            <v10:highestseverity xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">SUCCESS</v10:highestseverity>
            <v10:notifications xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
                <v10:severity>SUCCESS</v10:severity>
                <v10:source>crs</v10:source>
                <v10:code>0</v10:code>
                <v10:message>Request was successfully processed. </v10:message>
                <v10:localizedmessage>Request was successfully processed. </v10:localizedmessage>
            </v10:notifications>
            <v10:transactiondetail>
                <v10:customertransactionid></v10:customertransactionid>
            </v10:transactiondetail>
            <v10:version>
                <v10:serviceid>crs</v10:serviceid>
                <v10:major>10</v10:major>
                <v10:intermediate>0</v10:intermediate>
                <v10:minor>0</v10:minor>
            </v10:version>
            <v10:ratereplydetails xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
                <v10:servicetype>FIRST_OVERNIGHT</v10:servicetype>
                <v10:packagingtype>YOUR_PACKAGING</v10:packagingtype>
                <v10:deliverystation>TCMA </v10:deliverystation>
                <v10:deliverydayofweek>THU</v10:deliverydayofweek>
                <v10:deliverytimestamp>2011-06-16T08:30:00</v10:deliverytimestamp>
                <v10:commitdetails>
                    <v10:servicetype>FIRST_OVERNIGHT</v10:servicetype>
                    <v10:committimestamp>2011-06-16T08:30:00</v10:committimestamp>
                    <v10:dayofweek>THU</v10:dayofweek>
                    <v10:destinationservicearea>A2</v10:destinationservicearea>
                    <v10:brokertodestinationdays>0</v10:brokertodestinationdays>
                    <v10:documentcontent>NON_DOCUMENTS</v10:documentcontent>
                </v10:commitdetails>
                <v10:destinationairportid>SEA</v10:destinationairportid>
                <v10:ineligibleformoneybackguarantee>false</v10:ineligibleformoneybackguarantee>
                <v10:originservicearea>A2</v10:originservicearea>
                <v10:destinationservicearea>A2</v10:destinationservicearea>
                <v10:signatureoption>SERVICE_DEFAULT</v10:signatureoption>
                <v10:actualratetype>PAYOR_ACCOUNT_PACKAGE</v10:actualratetype>
                <v10:ratedshipmentdetails>
                    <v10:shipmentratedetail>
                        <v10:ratetype>PAYOR_ACCOUNT_PACKAGE</v10:ratetype>
                        <v10:ratescale>6</v10:ratescale>
                        <v10:ratezone>2</v10:ratezone>
                        <v10:pricingcode>PACKAGE</v10:pricingcode>
                        <v10:ratedweightmethod>ACTUAL</v10:ratedweightmethod>
                        <v10:dimdivisor>194</v10:dimdivisor>
                        <v10:fuelsurchargepercent>16.5</v10:fuelsurchargepercent>
                        <v10:totalbillingweight>
                            <v10:units>LB</v10:units>
                            <v10:value>1.0</v10:value>
                        </v10:totalbillingweight>
                        <v10:totalbasecharge>
                            <v10:currency>USD</v10:currency>
                            <v10:amount>46.3</v10:amount>
                        </v10:totalbasecharge>
                        <v10:totalfreightdiscounts>
                            <v10:currency>USD</v10:currency>
                            <v10:amount>0.0</v10:amount>
                        </v10:totalfreightdiscounts>
                        <v10:totalnetfreight>
                            <v10:currency>USD</v10:currency>
                            <v10:amount>46.3</v10:amount>
                        </v10:totalnetfreight>
                        <v10:totalsurcharges>
                            <v10:currency>USD</v10:currency>
                            <v10:amount>7.64</v10:amount>
                        </v10:totalsurcharges>
                        <v10:totalnetfedexcharge>
                            <v10:currency>USD</v10:currency>
                            <v10:amount>53.94</v10:amount>
                        </v10:totalnetfedexcharge>
                        <v10:totaltaxes>
                            <v10:currency>USD</v10:currency>
                            <v10:amount>0.0</v10:amount>
                        </v10:totaltaxes>
                        <v10:totalnetcharge>
                            <v10:currency>USD</v10:currency>
                            <v10:amount>53.94</v10:amount>
                        </v10:totalnetcharge>
                        <v10:totalrebates>
                            <v10:currency>USD</v10:currency>
                            <v10:amount>0.0</v10:amount>
                        </v10:totalrebates>
                        <v10:surcharges>
                            <v10:surchargetype>FUEL</v10:surchargetype>
                            <v10:description>Fuel</v10:description>
                            <v10:amount>
                                <v10:currency>USD</v10:currency>
                                <v10:amount>7.64</v10:amount>
                            </v10:amount>
                        </v10:surcharges>
                    </v10:shipmentratedetail>
                <v10:ratedshipmentdetails>
            </v10:ratereplydetails>
        </v10:ratereply>
    </soapenv:body>
</env:header>

試試這個連結...

http://blog.sherifmansour.com/?p=302

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM