Hello Rob,

> Do you have your code somewhere?

Yes, I paste it below. There are two files, one for HTML output (which I make 
invisible with style declaration "display:none;" and the second file is a 
javascript function which is supposed to output the content...

Another thing I realized that I failed to mention before is that
using saveXML($element) will serialize the full element, but outputs it in 
UTF-8 encoding. Have you tried converting the output of that to the encoding of 
the original HTML page? 

Well, I don't know any charset converting function which would be from standard 
library...


Here are the two files...

Thank you for your time...

LS


####################
code (1)
####################

class Stocks{

  var $doc;
  //var $source = Array("name" => "börse24", "url" => 
"http://boerse.n24.de/n24/kurse_listen.htm?sektion=TECDAX&awert=DEUTSCHLAND&u=0&k=0";);
  var $source = Array("name" => "börse24", "url" => "../data/file.html");
        
  var $ticker = "";

  function Stocks(){

    $this->doc = new DomDocument('1.0', 'UTF-8');
    //$this->doc->validateOnParse = true;
                
    $file = file_get_contents($this->source["url"]);
                
    //$file = preg_replace("/<img ([^>]*)>/", "", $file);
    $file = preg_replace("/&nbsp;/", "", $file);
    //$file = preg_replace("/±/", "&plusmn;", $file);
                
    $this->doc->loadHTML($file);
        
    $elements = $this->doc->getElementsByTagName("tr");
                
    $i = 0;             
                
    while( $elements->item($i) ){
                        
      if( $elements->item($i)->hasAttributes() && preg_match("/td[0|1]/", 
$elements->item($i)->getAttribute("id")) > 0 ){
                                
        $child_elements = $elements->item($i)->childNodes;
                        
        $j = 0;
        //$x = 0;
                                
        $this->ticker .= "<div name = 'stock'>\n";
                                
        while( $child_elements->item($j) ){     
          $this->ticker .= $child_elements->item($j)->textContent;
          if( $j == 4 ){
            $this->ticker .= " €";
          }                                     
          $this->ticker .= "--sep--";
          $j++;                                 
        }                                                       
        $this->ticker .= "</div>\n";
      }                 
      $i++;
    }
        
  $this->show();
        
  }
        
  function show(){      
    echo "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 
Transitional//EN\"\n\"http://www.w3.org/TR/html4/strict.dtd\";>";
    //echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" 
\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\";>\n";
    echo "<html>\n";
    echo "<head>\n";
    echo "<title>TecDax</title>\n";
    echo "<script src = '../javascript/tecdax.js' type = 
'text/javascript'></script>\n";
    echo "<meta http-equiv = 'content-type' content = 'text/html; 
charset=UTF-8'>\n";
    echo "</head>\n";
    echo "<body onLoad = 'getAllStocks();showAllStocks();'>\n";         
    echo "<div style = 'display:none;' id = 'tecdax'>\n";
    echo $this->ticker . "\n";
    echo "</div>\n";
    echo "</body>\n";
    echo "</html>\n";
  }
}

$stocks = new Stocks();


####################
code(2)
####################

/*
functions for tecdax stocks ticker
*/

var tecdax = "";

function getAllStocks(){
  tecdax = document.getElementById("tecdax").innerHTML;
}

function showAllStocks(){

  var stocks = document.getElementsByName("stock");
  var stock = new Array();
        
  for( i = 0 ; i < stocks.length ; i++ ){
                
    stock[i] = new Array();
    var tmp_stock = new Array();
    tmp_stock[i] = stocks[i].innerHTML;
                
    var attributes = tmp_stock[i].split("--sep--");
                
    var x = 0;
        
    for( j = 0 ; j < attributes.length ; j++ ){
                                
      var result = attributes[j].match(/\w/gi);                 
        
      if( ! result ){
        continue;
      }else{
        //attributes[j].replace(/[Â|±]+/,"");
        stock[i][x] = attributes[j] + " ";                              
        x++;
      }

    }
                
    alert(stock[i]);
                
  }
        
document.getElementById("tecdax").innerHTML = stock[0] + " " + stock[1];
document.getElementById("tecdax").style.fontSize = "11px";
document.getElementById("tecdax").style.display = "inline";
}

-- 
"Feel free" - 10 GB Mailbox, 100 FreeSMS/Monat ...
Jetzt GMX TopMail testen: http://www.gmx.net/de/go/topmail

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to