livewirerules Posted March 20, 2013 Share Posted March 20, 2013 I have a feed that contains over 10000 vehicles and is about 300 mb and trying to grab and display the name and the price of each vehicle.The problem is it displays all the data in the feed. Below is the feed that i used <vehicle> <type>Double Cab </type> <price>19.5k</price> <model>GTX</model> <descrip>sdsadasdasdsa</descrip> </vehicle> <vehicle> <type>Cruise </type> <price>78k</price> <model>Ultra</model> <descrip>sdsadasdasdsa</descrip> </vehicle> <vehicle> <type>Jeep/ Wagon </type> <price>2k</price> <model>Body Kit</model> <descrip>sdsadasdasdsa</descrip> </vehicle> I’m using the below code. $url = 'vcfeed.php'; $xname ="test"; $xPassword ="testuser"; $post_data = array("username" => $xname, "password" => $xPassword"); $ch = curl_init($url); $c[CURLOPT_POST] = true; $c[CURLOPT_POSTFIELDS] = $post_data; foreach($c as $k=>$v){$c[$k] = $v;} curl_setopt_array($ch,$c); $xml = curl_exec($ch); curl_close($ch); $z = new XMLReader; $z->open($xml); $doc = new DOMDocument; while ($z->read() && $z->name !== 'vehicle'); while ($z->name === 'vehicle') { $node = simplexml_import_dom($doc->importNode($z->expand(), true)); echo $node->model; echo $node->price; $z->next('vehicle'); } Although i have used echo $node->model; echo $node->price; It doesn’t show those 2 values for each result. Can someone tell me what am i doing wrong here? Link to comment https://forums.phpfreaks.com/topic/275901-issues-grabing-data-using-xmlreader-and-curl/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.