[phplib] About db_xsl.inc From: Jason Belich (macmaster <email protected>)
Date: 03/21/01

Hi,

I was just checking out db_xsl.inc. It's very cool, and i think i'll use it
in my next project. However, wouldn't it be better to change the
get_result_xml() method to:

  function get_result_xml() {
    $this->xml = "";
    $this->xml = $this->xml . '<?xml version="1.0"?>';
    $this->xml = $this->xml . '<result>';
    for ($index = 0; $index < DB_Sql::numrows(); $index++)
    {
      $this->xml = $this->xml . '<row>';
      DB_Sql::next_record();
      while (list($key, $val) = each($this->Record)) {
        $this->xml = $this->xml . '<' . $key . '>' . $this->xml_encode($val)
. '</' . $key . '>';
      }
      $this->xml = $this->xml . '</row>';
    }
    $this->xml = $this->xml . '</result>';
    return $this->xml;
  }

to get rid of the pgsql specificity? OR even better yet, use the DOM
functions like so:

  function get_xml_dom(){
    $this->xmldoc = new_xmldoc("1.0");
    $this->xmlroot = $this->xmldoc->add_root("result");
    for ($i=0;$i<DB_Sql::num_rows();$i++){
      $this->xmlnode[$i] = $this->xmlroot->new_child("row","");
      DB_Sql::next_record();
      while(list($key,$dataitem) = each($this->Record)){
         $this->xmlnode[$i]->new_child($key,$this->xml_encode($dataitem));
      }
    }
    return $this->xmldoc->dumpmem();
  }

Note: I haven't tested this yet, but it seems to me to be more correct.

Regards

Jason Belich

---------------------------------------------------------------------
To unsubscribe, e-mail: phplib-unsubscribe <email protected>
For additional commands, e-mail: phplib-help <email protected>