Jump to content

Issues grabing data using XMLReader and CURL


Recommended Posts

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



      <type>Double Cab </type>

      <type>Cruise </type>

      <type>Jeep/ Wagon </type>
      <model>Body Kit</model>


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;}

$xml = curl_exec($ch);


$z = new XMLReader;

$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;





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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.