Hello,
Can anyone tell why the second if statement pulling the soldby name wouldn’t work properly?
What I want it to do is name pull the alt attribute from the image, if there is an image for the seller - which works. But if there isn’t an image logo, there is a bold tag with the seller name which I want to be inserted in the same place in the array that the alt tag would be.
The HTML I am working with is: http:// amazon.com/gp/offer-listing/B002UYSHMM
Can anyone help?
Thank you!
[php]
$item = array();
foreach ($html->find(‘div.resultsset table tbody.result tr’) as $article) {
if ($article->find(‘span.price’, 0)) {
// get retail
$item[$retail.$i++] = $article->find(‘span.price’, 0)->plaintext;
// get soldby
if ($article->find(‘ul.sellerInformation img’, 0)) {
$item[$soldby.$j++] = $article->find(‘ul.sellerInformation img’, 0)->getAttribute(‘alt’);
} else {
$item[$soldby.$j++] = $article->find(‘ul.sellerInformation li a b’, 0)->plaintext;
}
$ret[‘SellerInfo’] = $item;
}
}
[/php]
Here is the array I get out of my code above:
Array ( [0] => Array ( [Retail] => $219.88 [SoldBy] => J&R Music and Computer World ) [1] => Array ( [Retail] => $234.21 [SoldBy] => PORTABLE GUY ) [2] => Array ( [Retail] => $235.73 [SoldBy] => The Price Pros ) [3] => Array ( [Retail] => $234.74 [SoldBy] => GizmosForLife ) [4] => Array ( [Retail] => $230.00 [SoldBy] => ) [5] => Array ( [Retail] => $198.73 [SoldBy] => ) [6] => Array ( [Retail] => $240.72 [SoldBy] => ) [7] => Array ( [Retail] => $248.99 [SoldBy] => onSale ) )
You can see that it is missing SoldBy for:
STEPHS GREAT BOOK TREASURES
Diakonos23
OptimumHouse