XML Read with Variable Subset Data problem

I know my code works as I use it to pull from the yahoo database with ease. My problem with this other search engine is their variable data as shown in the example xml code.

The Subset of results is Site
They use a Site index=“1” and that is where I don’t know how to call that subset without creating loops which defeats the whole purpose of reading xml to begin with.

You can look at the example xml live at http://www.sharedfeed.com/7search_example.xml
[php]
$search_url = simplexml_load_file(“7search_example.xml”);

foreach ($search_url->results->site as $search_url_info)
{
$url = $search_url_info->url;
$title = $search_url_info->name;
$description = $search_url_info->description;
$bid = $search_url_info->bid;
$dispurl = $search_url_info->httplink;

$data = "INSERT INTO database SET id=’’, url=’$url’, title=’$title’, description=’$description’, bid=’$bid’, dispurl=’$dispurl’, keyword=’$keywords’, time=’’ ";

$data_result = mysql_query($data);

}

[/php]

[php]

<?xml version="1.0" encoding="ISO-8859-1" standalone="yes"?> [/php]

Ok once again I asked a problem to tough for the community to get help from, but I did finally figure out my own answer.

Change the foreach statement to the following which places the data in an array and prevents creating loops.
[php]foreach ($xmlObject->children() as $node) {
$arr = $node->attributes(); // returns an array
//print (“SITE=”.$arr[“INDEX”]);
$index = $arr[“SITE”];
$url = $node->URL;
$title = $node->NAME;
$description = $node->DESCRIPTION;
$bid = $node->BID;
$dispurl = $node->HTTPLINK;
[/php]

Capitalization is important The array does not string to lower the xml tags so if you have Goofy tags Like JjkK you must call them same way.

No company should be using attribute xml it was billed as bigger overhead but what you lose in portability because pushing the data to ta database isn’t as straight forward as elemental xml is not worth dropping yourself to 3% of the market capable of reading your stuff.

Don’t let your IT guy run your company:)

That’s a terrible attitude, if you need help on the same day you shouldn’t rely on a free discussion forum but use some kind of paid service.

The people here are helping for free, and we have members with all kinds of special fields and skill levels. As we’re drawing close to christmas atleast I can’t prioritise time to fiddle with this kind of stuff atm, guess that’s the case for many others as well.

That depends on the IT-guy, but the IT-guys capable of running their own company probably already does ^^

Sponsor our Newsletter | Privacy Policy | Terms of Service