Posted By

velinea on 07/08/06


Tagged

xml


Versions (?)

Who likes this?

10 people have marked this snippet as a favorite

alexsancho
Taleamus
takushi
vali29
oli964
JimiJay
nb109
tapdrup
dimispaceman
ringo380


Parse xml


 / Published in: PHP
 

  1. function read_xml($file) {
  2. $fh = fopen("$file",'r') or die($php_errormsg);
  3. $simple = fread($fh,filesize("$file"));
  4. fclose($fh) or die($php_errormsg);
  5.  
  6. xml_parse_into_struct($p, $simple, $vals, $index);
  7. $meta[status] = $vals[$index[STATUS][0]][value];
  8. $meta[paiva] = $vals[$index[PAIVA][0]][value];
  9. $meta[alkuaika] = $vals[$index[ALKUAIKA][0]][value];
  10. $meta[loppuaika] = $vals[$index[LOPPUAIKA][0]][value];
  11. $meta[tiedosto] = $vals[$index[TIEDOSTO][0]][value];
  12. $meta[koko] = $vals[$index[KOKO][0]][value];
  13. $meta[otsikko] = $vals[$index[OTSIKKO][0]][value];
  14. $meta[tyyppi] = $vals[$index[TYYPPI][0]][value];
  15. $meta[kohde] = $vals[$index[KOHDE][0]][value];
  16. $meta[lahde] = $vals[$index[LAHDE][0]][value];
  17. $meta[toimittaja] = $vals[$index[TOIMITTAJA][0]][value];
  18. $meta[teksti] = $vals[$index[TEKSTI][0]][value];
  19. return $meta;
  20. }

Report this snippet  

You need to login to post a comment.