Jump to content

Recommended Posts

I have some code that uses simpleXML to parse the contents of a google base xml file. Currently i have it looping thru and echo'ing the desired information. I want to be able to have more control of the data allowing me to sort, filter, and maybe even graph the output.

Would it be better to use a MySQL database to store the results or should I use an array? I'm not very comfortable with multideminsional arrays even after reading several tutorials.

Here is the code snippet:

[color=blue]$xml = simplexml_load_file($file) or die ("Unable to load XML file!");

// build the table and display results by looping thru each element
echo "<table>";
foreach ($xml->entry As $entry)
{
// set the namespace for g:children using http://base.google.com/ms/1.0
$ns_g = $entry->children('http://base.google.com/ns/1.0');
// output the desired content

echo "<tr>";
echo "<td>";
echo $ns_g->year . " ";
echo "</td>";
echo "<td>";
echo $ns_g->make . " ";
echo "</td>";
echo "<td>";
echo $ns_g->model . " ";
echo "</td>";
echo "<td>";
echo $ns_g->trim . " ";
echo "</td>";
echo "<td>";
echo $ns_g->mileage . " ";
echo "</td>";
echo "<td>";
echo $ns_g->price;
echo "<br />";
echo "</td>";
echo "</tr>";

}[/color]

Thanks for any advice/instruction you can provide me  :)
[quote author=dgiberson link=topic=122838.msg507087#msg507087 date=1169058375]
I guess it all depends how far down the line you want to access this information... if it's a one time thing go with an array, otherwise setup a table to store the information.
[/quote]

It will be a one time thing, becuase the xml file being parsed will be different every time. The information would only be used short term, basicly session length.

given the code above, how would you recommend replacing the current echo output with saving the data to an array?

Thank you again
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.

Guest
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.