Location: PHPKode > projects > SolBT > sol/modulos.xml.php
<?php
  include("../sol/sessao.php");
  
  $dados = new dados();
  $dados->get_conexao();
  
  $sql = "SELECT * FROM modulo WHERE sistema = ".$_POST["id"]." ORDER BY modulo ASC";
  
  $rs = mysql_query($sql);
  
  if (mysql_num_rows($rs) > 0)
  {
    //Cria XML
    $xml = new DOMDocument("1.0", "UTF-8");
    $xml->preserveWhiteSpace = false;
    $xml->formatOutput = true;

    //Insere nó principal
    $root = $xml->createElement("modulos");
    
    while ($reg = mysql_fetch_array($rs))
    {
      $codigo = $xml->createElement("codigo", $reg["id_modulo"]);
      $nome = $xml->createElement("nome", utf8_encode($reg["modulo"]));
      
      //Cria nó de registro
      $modulo = $xml->createElement("modulo");
      
      //Adiona campos com os valores
      $modulo->appendChild($codigo);
      $modulo->appendChild($nome);
      
      //Adiciona o registro ao noh prncipal
      $root->appendChild($modulo);
    }
    
    //Fecha a TAG do nó principal
    $xml->appendChild($root);

    //Imprime o XML na tela
    Header("Content-Type: text/xml");
    echo $xml->saveXML();
  }
  
  @mysql_close();
?>
Return current item: SolBT