2013-10-13 3 views
0

첫 번째 조건 만 감지 할 수 있습니다. 그 밖의 경우에는 아무 것도 작동하지 않습니다. xpath가 정확합니다. 만약 내가 루프없이 그것을 작동합니다. 내가 여기서 뭘 잘못한거야? 항상 사실 때문에 else 블록이 평가되지 않습니다되기 때문에isEmpty 루핑

$pricediscount = ""; 
$chinesename =""; 


if (empty($pricediscount)){ 
     $pricediscount = (@$xpath->query("//*[@id='J_PromoPrice']/div/strong/text()")->item(0)->nodeValue); 
    }elseif(empty($pricediscount)){ 
     $pricediscount = (@$xpath->query("//*[@id='J_StrPrice']/em[2]")->item(0)->nodeValue); 
    }elseif(empty($pricediscount)){ 
     $pricediscount = (@$xpath->query("//*[@id='J_PromoBox']/strong")->item(0)->nodeValue); 
    }elseif(empty($pricediscount)){ 
     $pricediscount = (@$xpath->query("//*[@id='J_StrPrice']")->item(0)->nodeValue); 
    }else{ 
     $pricediscount = "NA"; 
    } 
+2

글쎄, 당신은 동일한 조건을 3 번 테스트하고 있습니다 ... 정확히 무엇을하려하고 있습니까? – elclanrs

+0

첫 번째 else if가 비어 있으면 – CodeGuru

+0

첫 번째 요소가 비어 있으면 다른 요소도 비어 있습니다. 같은 것을 계속 반복해서 테스트하고 있습니다 ... 나는 당신의 논리가 무엇인지 이해하지 못합니다. – elclanrs

답변

2

혹시 첫 번째 if 문을 실행합니다. elseifelse 문을 if으로 변경해보세요.