jeudi 16 septembre 2021

Filtering the page with xml

I want to filter websites using xml depending on whether the values are contained in it or not. I have such a script and I don't know why, but it filters well once, not, can anyone advise me something?

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE note SYSTEM "Note.dtd">
<filter>
<min_szerokosc>111</min_szerokosc>
<min_wysokosc>111</min_wysokosc>
<min_glebokosc>111</min_glebokosc>
<max_szerokosc>1111</max_szerokosc>
<max_wysokosc>1111</max_wysokosc>
<max_glebokosc>1111</max_glebokosc>
<typ>power&free</typ>
<myjnia_automat>1</myjnia_automat>
<kabina_automat>1</kabina_automat>
<transport_gorny>1</transport_gorny>
<extra></extra>
</filter>

<?php

$cat=new Kategoria;

$kat=array(205,233,234,206,204,203,202);
//$kat=array(206);

foreach($_POST as $k => $v){
    if($v=="on"){
    $_POST[$k]=1;
    }
}

foreach($kat as $a => $b){

$result=$cat->getKategoria($b);

//print_r($_POST);

foreach($result as $res => $val){
    if(preg_match("/tab_[0-9]{1,2}_filter/i",$res)>0){
    //print_r($val);
    $xml = simplexml_load_string($val);

        if($xml){
        
        if($_POST['typ'] == $xml->typ){
        
        if($_POST['min_szerokosc'] <= $xml->min_szerokosc && 
        $_POST['min_wysokosc'] <= $xml->min_wysokosc   && 
        $_POST['min_glebokosc'] <= $xml->min_glebokosc && 
        $_POST['max_szerokosc'] <= $xml->max_szerokosc &&
        $_POST['max_wysokosc'] <= $xml->max_wysokosc   &&
        $_POST['max_glebokosc'] <= $xml->max_glebokosc &&
        $_POST['myjnia_automat'] == $xml->myjnia_automat ||
        $_POST['myjnia_reczna'] == $xml->myjnia_reczna ||
        $_POST['wanna'] == $xml->wanna &&
        $_POST['kabina_automat'] == $xml->kabina_automat ||
        $_POST['kabina_jedno_stanowiskowa'] == $xml->kabina_jedno_stanowiskowa ||
        $_POST['kabina_dwu_stanowiskowa'] == $xml->kabina_dwu_stanowiskowa &&
        $_POST['transport_gorny'] == $xml->transport_gorny ||
        $_POST['transport_dolny'] == $xml->transport_dolny){

        print "true:{$b}:{$res} \n";               
       }else{
       //print "false\n";
       //print("{$_POST['typ']} == $xml->typ");
                        }   
                    }
                }
    //print($res."\n");
        }
    }
}

?>

How do I compose an if statement to be able to refer to each of the values of the xml file ?

How can I filter this simple xml?

Aucun commentaire:

Enregistrer un commentaire