function add_url($sid, $URL) { $xmldoc = new DOMDocument(); $xmldoc->load('0.ktr'); $xpathvar = new Domxpath($xmldoc); $queryResult = $xpathvar->query('//step/file/name[@id="url"]'); $queryResult2 = $xpathvar->query('//step/spreadsheet_type[@id="sheet_type"]'); $extension = pathinfo($URL, PATHINFO_EXTENSION); if ($extension == 'xls') { $queryResult2->item(0)->nodeValue = "JXL"; } else { if ($extension == 'xlsx') { } } foreach ($queryResult as $result) { $result->nodeValue = $URL; } print $xmldoc->save('0.ktr'); }
/** * Api function for crawl bank daily data. * * @return Response */ public function getBankDaily() { $apies = json_decode(EXR_BANKS); // Crawl bank api url. foreach ($apies as $type => $url) { switch ($type) { case 'VCB': $content = file_get_contents($url); if (!$content) { return false; } $doc = new \Domdocument(); @$doc->loadxml($content); $xpath = new \Domxpath($doc); $items = $xpath->query('//Exrate'); $codes = array(); foreach ($items as $item) { $codes[] = $item->getattribute('CurrencyCode'); } // get currency by ids $currencies = Currency::getCurrenciesByCodes($codes, $type); // get exchange rates over bank api. if (count($currencies)) { foreach ($currencies as $currency) { $item = $xpath->query('//Exrate[@CurrencyCode="' . $currency->code . '"]')->item(0); $currencyid = $currency->id; $buy = $item->getattribute('Buy'); $transfer = $item->getattribute('Transfer'); $sell = $item->getattribute('Sell'); if ($buy && $transfer && $sell) { CurrencyDaily::updateExratesDaily($currencyid, $buy, $transfer, $sell, 'bank'); } } } break; } } return Response::json(array('status' => 'Success', 'data' => $apies), 200); }
<?php $doc = new DOMDocument(); $doc->formatOutput = true; $getId = $_GET['id']; $file = $_GET['file']; $count = intval($_GET['reg']); if ($xml = file_get_contents($file)) { $doc->loadXML($xml, LIBXML_NOBLANKS); $xpath = new Domxpath($doc); $check = 'upc' . ($count + 1); $ent = $xpath->query('//entity[@name="' . $getId . '"]'); $c = $ent->item(0); $g = $c->getElementsByTagName($check); if ($g->length == 0) { $entities = $xpath->query('//entity[@name="' . $getId . '"]/keyword1'); $t = array(); for ($i = 0; $i < 8; $i++) { $in = 'upc' . ($count + $i + 1); $t[$i] = $doc->createElement($in); $refNode = $entities->item(0); $refNode->parentNode->insertBefore($t[$i], $refNode); } header('Content-Type: text/plain'); echo $doc->save($file); } else { echo 'true'; } }
* @author: Skiychan<*****@*****.**> * @created: 1/6/15 21:15 * @modified: */ //lang={cn / en} //https://www.ecmsglobal.com/oms/showtracking?trackingno=APELAX1040039963&lang=cn // $lang = "cn"; $postid = isset($_GET['postid']) ? $_GET['postid'] : 0; $kd_url = "https://www.ecmsglobal.com/oms/showtracking?trackingno={$postid}&lang={$lang}"; $page_info = file_get_contents($kd_url); //$page_info = file_get_contents("a.html"); $page_dom = "<meta http-equiv='Content-Type' content='text/html; charset=utf-8'/>" . $page_info; $xmldoc = new DOMDocument(); @$xmldoc->loadHTML($page_dom); $xmldoc->normalizeDocument(); $page_xml = new Domxpath($xmldoc); $event_date = $page_xml->query('//div[@class="order"]//ul//div[@class="column event_date"]'); $event_where = $page_xml->query('//div[@class="order"]//ul//div[@class="column event_where"]'); $event_desc = $page_xml->query('//div[@class="order"]//ul//div[@class="column event_desc"]'); $thisinfo = array(); $add_infos = array(); foreach ($event_date as $keys => $values) { $location = $event_where->item($keys)->textContent; $context = $event_desc->item($keys)->textContent; $thisinfo[] = array('time' => $values->textContent, 'location' => $location, 'context' => $location . ",\n" . $context); } if (count($thisinfo) > 0) { $add_infos = array('message' => "ok", 'nu' => $postid, 'companytype' => "ecms", 'ischeck' => "1", 'com' => "ecms", 'updatetime' => $event_date->item(0)->textContent, 'status' => "200", 'codenumber' => $postid, 'data' => $thisinfo); } return $add_infos;
function check_for_redirect() { global $post; $url = NULL; if ($this->WikiHelper->is_wiki('front_end_check')) { $content = trim($post->post_content); if (preg_match('/^#REDIRECT \\[\\[.*\\]\\]$/', $content)) { $content = $this->wiki_parser($content); $domDoc = new DOMDocument(); $domDoc->loadHTML($content); $xp = new Domxpath($domDoc); $q = $xp->query('//a/@href'); foreach ($q as $r) { $url = $r->textContent; } } } if (!is_null($url)) { header("Location: " . esc_url($url)); exit; } }
<?php $doc = new DOMDocument(); $doc->formatOutput = true; $getId = $_GET['id']; $file = $_GET['file']; $count = $_GET['tick'] + 1; if ($xml = file_get_contents($file)) { $doc->loadXML($xml, LIBXML_NOBLANKS); $xpath = new Domxpath($doc); $entities = $xpath->query('//entity[@name="' . $getId . '"]'); $in = 'keyword' . $count; $ent = $doc->createElement($in); $refNode = $entities->item(0); $refNode->appendChild($ent); } header('Content-Type: text/plain'); echo $doc->save($file);