<?php

/**
 * File name: 
 * 
 *
 * (C) Copyright 2013 Friedrich-Ebert-Stiftung (http://fes.ro)
 * Author: Tiberiu C. Turbureanu (tct@ceata.org)
 *
 * This file is part of the project funded by FES
 *
 * This is free software; you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as published by
 * the Free Software Foundation; either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

$v = new DOMDocument();
$v->formatOutput = true;
$t = $v->appendChild($v->createElement("table"));

$html = file_get_contents('../documente/candidații-pentru-bucurești-2012.html');
$doc = new DOMDocument();
$doc->loadHTML($html);
$xpath = new DOMXpath($doc);

$elements = $xpath->query("//tr[@class='ro2']");

foreach ($elements as $e)
{
  $party = $xpath->query("td/p", $e)->item(4)->nodeValue;

  if ($party == "62" || $party == "15" || $party == "57")
  {
    $t->appendChild($v->importNode($e->cloneNode(true), true));
  }
}

$v->saveHTMLFile('../documente/victorioșii-din-bucurești-2012.html');

?>
