Ver Mensaje Individual
  #3 (permalink)  
Antiguo 08/02/2013, 13:55
xoceunder
 
Fecha de Ingreso: junio-2012
Ubicación: En el Mundo
Mensajes: 759
Antigüedad: 11 años, 10 meses
Puntos: 10
Respuesta: duda para juntar informacion de 2 xml

ok mira tengo esto ya funcionando pero solo para un xml

Código PHP:
Ver original
  1. <?php
  2.  
  3.     $sql = mysql_query("SELECT * FROM settings WHERE id='1'");
  4.     $line=mysql_fetch_array($sql);
  5.     if ($line["srv_from"] == "1" ) {
  6.         $showuseronline = "1";
  7.     } else {
  8.         $showuseronline = "0";
  9.     }
  10.         if ($showuseronline == "1") {
  11.             $i = 0;
  12.             $srv_ip = $line["srv_ip"];
  13.             $srv_port = $line["srv_port"];
  14.             $srv_user = $line["srv_user"];
  15.             $srv_pass = $line["srv_pass"];
  16.             $srv_protocol = $line["srv_protocol"];
  17.             $xml = simplexml_load_file($srv_protocol."://".$srv_user.":".$srv_pass."@".$srv_ip.":".$srv_port."/xmlHandler?command=users-1");
  18.             $proxyusers = "users-1";
  19.                 foreach($xml->$proxyusers->user as $users) {
  20.                     $y = 0;
  21.                     $activesession = 0;
  22.                     $userstate = "0";
  23.                     $xmlusername = "";
  24.                     foreach($xml->$proxyusers->user[$i]->session as $active) {
  25.                         if ((string)$xml->$proxyusers->user[$i]->session[$y]->attributes()->active == "true") {
  26.                             $userstate = "1";
  27.                             $activesession = $y;
  28.                         }
  29.                         $y++;
  30.                     }
  31.                     $activeusers[] = (string)$xml->$proxyusers->user[$i]->attributes()->name;
  32.                     $activeusersstate[(string)$xml->$proxyusers->user[$i]->attributes()->name] = $userstate;
  33.                     $xmlusername = (string)$xml->$proxyusers->user[$i]->attributes()->name;
  34.                         if ($userstate == "1") {
  35.                             $userinfo[$xmlusername."-servname"] = @(string)$xml->$proxyusers->user[$i]->session[$activesession]->service->attributes()->name;
  36.                         } else {
  37.                             $userinfo[$xmlusername."-servname"] = "";
  38.                         }
  39.                     $i++;
  40.                 }
  41.         }