123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293 |
- <?php
- require_once 'utile.php';
- $inames = array();
- $xml = new DOMDocument();
- $xml->load('../20131013-consilieri.xml');
- $xpath = new DOMXpath($xml);
- $persons = $xpath->query("/xml/person");
- foreach($persons as $person)
- {
-
- $comname = $xpath->query("comname", $person)->item(0)->nodeValue;
- $surname = $xpath->query("surname", $person)->item(0)->nodeValue;
- $inames[] = $comname.'-'.$surname;
- }
- $v = new DOMDocument();
- $v->formatOutput = true;
- $table = $v->appendChild($v->createElement("table"));
- $html = file_get_contents('../documente/victorioșii-din-bucurești-2012.html');
- $doc = new DOMDocument();
- $doc->loadHTML($html);
- $xpath = new DOMXpath($doc);
- $elements = $xpath->query("//tr[@class='ro2']");
- foreach ($elements as $e)
- {
- $fullname = $xpath->query("td/p", $e)->item(6)->nodeValue;
- $fullname = fărăDiacritice(utf8_encode(strtolower($fullname)));
- $fnames = explode(" ", $fullname);
- $fsurnames = trim($fnames[0]);
- $fsurnames = explode("-", $fsurnames);
- $fcomnames = array();
- for ($k = 1; $k < count($fnames); $k++)
- {
-
- preg_match('/[a-z-]+/', $fnames[$k], $temp);
- $temps = explode("-", $temp[0]);
- foreach ($temps as $t)
- {
- $fcomnames[] = trim($t);
- }
- }
- foreach ($inames as $i)
- {
- $names = explode("-", $i);
- $comname = $names[0];
- $surname = $names[1];
- if (in_array($surname, $fsurnames) && in_array($comname, $fcomnames))
- {
- $table->appendChild($v->importNode($e->cloneNode(true), true));
- }
- }
- }
- $v->saveHTMLFile('../documente/aleșii-din-bucurești-2012.html');
- ?>
|