开发者

parse xml with php

i have a xml response as below -

<NewDataSet> <Account> <CustCode>UZ6CMAIN</CustCode> <GUID>f5b0866b-2f67-48c5-993b-c67895bb0489</GUID> <Features>0</Features> <BaseCCY>USD</BaseCCY> <LastOrderSEQ>160928459</LastOrderSEQ> <LastDealSEQ>160928461</LastDealSEQ> <OrderLotSize>100000</OrderLotSize> <MaxOrderPips>1000</MaxOrderPips> <CancelOrderPips>开发者_如何转开发1</CancelOrderPips> <TradeLotSize>100000</TradeLotSize> <MaxTradeLots>25</MaxTradeLots> <TierCount>1</TierCount> <Tier1MinLots>1</Tier1MinLots> <Tier1MaxLots>50</Tier1MaxLots> <Tier1PipDifference>0</Tier1PipDifference> <Tier2MinLots>0</Tier2MinLots> <Tier2MaxLots>0</Tier2MaxLots> <Tier2PipDifference>0</Tier2PipDifference> <Tier3MinLots>0</Tier3MinLots> <Tier3MaxLots>0</Tier3MaxLots> <Tier3PipDifference>0</Tier3PipDifference> </Account> </NewDataSet>

using the following code -

$xml = simplexml_load_string($result);

print_r($xml);

gives -

SimpleXMLElement Object ( [0] => UZ6CMAIN 02267a97-4428-401d-81e1-d0010d559470 0 USD 160928459 160928461 100000 1000 1 100000 25 1 1 50 0 0 0 0 0 0 0 ) 

Now how do i access the individual elements like value inside GUID tag and BaseCCY tags etc..Thanks for help.


That seem strange, Because when i ran your code I got the output as

SimpleXMLElement Object ( [Account] => SimpleXMLElement Object ( [CustCode] => UZ6CMAIN [GUID] => f5b0866b-2f67-48c5-993b-c67895bb0489 [Features] => 0 [BaseCCY] => USD [LastOrderSEQ] => 160928459 [LastDealSEQ] => 160928461 [OrderLotSize] => 100000 [MaxOrderPips] => 1000 [CancelOrderPips] => 1 [TradeLotSize] => 100000 [MaxTradeLots] => 25 [TierCount] => 1 [Tier1MinLots] => 1 [Tier1MaxLots] => 50 [Tier1PipDifference] => 0 [Tier2MinLots] => 0 [Tier2MaxLots] => 0 [Tier2PipDifference] => 0 [Tier3MinLots] => 0 [Tier3MaxLots] => 0 [Tier3PipDifference] => 0 ) )


print ((String) $xml->Account->GUID);

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜