0

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.

2 Answers 2

1

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 ) )
Sign up to request clarification or add additional context in comments.

1 Comment

it is strange..xml seems to be improper.
0

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.