2015-02-01 23:21

通过xmlwriter PHP在xml文件中写入数据

Hello my script is creating xml file with two elements in it but im not able to adding next element(name = item) to created xml file. can anyone help me?? :) can i load file enter items add one item and save file???

  $content = file_get_contents('http://evidujem.sk');
  preg_match('#<br /><b> (.*?) užívateľov</b>#', $content, $match);
  $pocet = $match[1];

  $writer = new XMLWriter();
  $writer->setIndentString('  ');
  $writer->startDocument('1.0', 'UTF-8');
  $writer->writeAttribute('aktualny_datum', date('j.n. Y'));
  $writer->text('pocet registrovanych:' . $pocet);

  $filename = 'pocet.xml';
  $file = $writer->outputMemory();


output in the xml file shoul be:

<items><item date="aktualny datum">pocet registrovanych</item>
  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答