thejargen Posted February 28, 2013 Share Posted February 28, 2013 Hi, Im trying to use the eBay API to get all my purchases. I have managed to do that, but trying to use the data it returns is proving tricky. Here is my code which parses the output: function syncebay() { $xml = simplexml_load_string(constructPostCallAndGetResponse()); $amount = count($xml->OrderArray->Order); //echo $amount; $i = 0; while($i < $amount) { $return[$i][0] = (string) $xml->OrderArray->Order[$i]->TransactionArray->Transaction->Item->Title; $i++; } print_r($return); } But that outputs Array ( [0] => Array ( [0] => HP ZE4700 Laptop Spares Or Repair ) [1] => Array ( [0] => BlackBerry Curve 8520 - Black (Unlocked) Smartphone broken spares or reparis ) [2] => Array ( [0] => Blackberry Bold(needs new screen). ) [3] => Array ( [0] => MICRO USB DATA CABLE CHARGER LEAD BLACKBERRY HTC SAMSUNG NOKIA SONY ERRICSSON ) [4] => Array ( [0] => DC JACK HP ZE4000 ZE4100 ZE4200 ZE4300 ZE4500 ZE4700 NE ) [5] => Array ( [0] => 10 x Long Shallow Postal Packing Mailing Storage Cardboard Boxes 18x12x4" SW ) [6] => Array ( [0] => QUALITY SINGLE WALL POSTAL MAILING CARDBOARD BOXES[6" x 6" x 6" (152x152x152mm),25] ) [7] => Array ( [0] => Genuine HP Compaq nc6320 nc6120 nc6110 nx6110 nx6120 nx6310 Inverter ) [8] => Array ( [0] => blackberry 8520 ) [9] => Array ( [0] => 180° Tilt Swivel LCD TV Wall Mount bracket for 14”- 24” ) [10] => Array ( [0] => BUBBLE WRAP - 300mm 500mm 600mm 750mm - 10m 20m 30m 50m 100m ROLLS[100m x 500mm] ) [11] => Array ( [0] => 10 x Long Shallow Postal Packing Mailing Storage Cardboard Boxes 18x12x4" SW ) [12] => Array ( [0] => Gateway W323-UI1 LCD Screen Inverter 3A:1603284771 ) [13] => Array ( [0] => MICROSIM MICRO Mini SIM CARD ADAPTER CONVERTER ADAPTOR to standard normal / x 2 ) ) Instead of just the title. I cant work out why it does that, or how. Here is the transaction section of the XML for one of the objects: <Transaction> <Buyer> <Email>XXXXXXXX</Email> </Buyer> <ShippingDetails> <SellingManagerSalesRecordNumber>556</SellingManagerSalesRecordNumber> </ShippingDetails> <CreatedDate>2013-02-07T17:16:33.000Z</CreatedDate> <Item> <ItemID>111008202399</ItemID> <Site>UK</Site> <Title>HP ZE4700 Laptop Spares Or Repair</Title> <ConditionID>7000</ConditionID> <ConditionDisplayName>For parts or not working</ConditionDisplayName> </Item> <QuantityPurchased>1</QuantityPurchased> <Status> <PaymentHoldStatus>None</PaymentHoldStatus> </Status> <TransactionID>0</TransactionID> <TransactionPrice currencyID="GBP">7.0</TransactionPrice> <TransactionSiteID>US</TransactionSiteID> <Platform>eBay</Platform> <Variation /> <OrderLineItemID>111008202399-0</OrderLineItemID> </Transaction> </TransactionArray> Any help? Thaks. Quote Link to comment https://forums.phpfreaks.com/topic/275050-xml-issues/ Share on other sites More sharing options...
Solution thejargen Posted February 28, 2013 Author Solution Share Posted February 28, 2013 Me being silly and reading it wrong. SOLVED. Quote Link to comment https://forums.phpfreaks.com/topic/275050-xml-issues/#findComment-1415620 Share on other sites More sharing options...
Barand Posted February 28, 2013 Share Posted February 28, 2013 foreach ($xml->xpath('//Item/Title') as $t) { $titles[] = (string)$t; } Quote Link to comment https://forums.phpfreaks.com/topic/275050-xml-issues/#findComment-1415623 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.