function parse($xml) { $this->name = getValue($xml, 'name'); $this->category = getValue($xml, 'category'); $this->subcategory = getValue($xml, 'subcategory'); $this->usage = getValue($xml, 'usage'); $this->returns = getValue($xml, 'returns'); $this->related = getValue($xml, 'related'); $this->related = preg_split("/\n/", $this->related, -1, PREG_SPLIT_NO_EMPTY); $this->availability = getValue($xml, 'availability'); $this->partof = getValue($xml, 'partof'); $this->level = getValue($xml, 'level'); $this->type = getValue($xml, 'type'); $this->hasParameter = getValue($xml, 'label'); // Added for 149 $this->hasCode = getValue($xml, 'code'); // Added for 149 $this->description = innerHTML($xml, 'description'); $this->syntax = innerHTML($xml, 'syntax'); $this->constructor = innerHTML($xml, 'constructor'); $this->examples = getFragmentsAsArray($xml, 'example', array('image', 'code')); $this->fields = getFragmentsAsArray($xml, 'field', array('fname', 'fdescription')); $this->methods = getFragmentsAsArray($xml, 'method', array('mname', 'mdescription')); $this->parameters = getFragmentsAsArray($xml, 'parameter', array('label', 'description')); $this->cparameters = getFragmentsAsArray($xml, 'cparameter', array('clabel', 'cdescription')); }
function format($node, $def) { switch ($def->type) { case 'text': default: return $node->textContent; break; case 'attribute': if ($def->attribute == 'href') { return $node->getAttribute($def->attribute); } else { return $node->getAttribute($def->attribute); } break; case 'match': if (preg_match(sprintf('/%s/', $def->match), $node->textContent, $matches)) { return $matches[1]; } break; case 'html': $d = new DOMDocument(); $d->appendChild($d->importNode($node, TRUE)); return $d->saveHTML(); break; case 'innerhtml': return innerHTML($node); break; } }
function node_data($node, $type, $attr = NULL) { $node = simplexml_import_dom($node); if ($attr) { $node = $node[$attr]; } switch ($type) { case 'html': $result = innerHTML(dom_import_simplexml($node)); break; case 'text': default: $result = (string) $node; break; } return $result; }
function Curated($xml) { $this->name = getAttribute($xml, 'name'); $this->by = getAttribute($xml, 'by'); $this->scroll = getAttribute($xml, 'scroll'); $this->resize = getAttribute($xml, 'resize'); $this->width = getAttribute($xml, 'width'); $this->height = getAttribute($xml, 'height'); $this->image = getValue($xml, 'image'); $this->description = innerHTML($xml, 'description'); $this->location = getValue($xml, 'location'); $links = $xml->getElementsByTagName('link'); $links = $links->toArray(); foreach ($links as $link) { $this->links[] = array('href' => $link->getAttribute('href'), 'title' => $link->getText()); } }
/** * Helper, returns the innerHTML of an element * * @param object DOMElement * * @return string one element's HTML content */ function innerHTML($contentdiv) { $r = ''; $elements = $contentdiv->childNodes; foreach ($elements as $element) { if ($element->nodeType == XML_TEXT_NODE) { $text = $element->nodeValue; // IIRC the next line was for working around a // WordPress bug //$text = str_replace( '<', '<', $text ); $r .= $text; } elseif ($element->nodeType == XML_COMMENT_NODE) { $r .= ''; } else { $r .= '<'; $r .= $element->nodeName; if ($element->hasAttributes()) { $attributes = $element->attributes; foreach ($attributes as $attribute) { $r .= " {$attribute->nodeName}='{$attribute->nodeValue}'"; } } $r .= '>'; $r .= innerHTML($element); $r .= "</{$element->nodeName}>"; } } return $r; }
/** * Helper function from http://kuttler.eu/post/php-innerhtml/ * Allows the innerHTML of a table cell to be extracted. */ function innerHTML($contentdiv) { $r = ''; $elements = $contentdiv->childNodes; foreach ($elements as $element) { if ($element->nodeType == XML_TEXT_NODE) { $text = $element->nodeValue; $r .= $text; } elseif ($element->nodeType == XML_COMMENT_NODE) { $r .= ''; } else { $r .= '<'; $r .= $element->nodeName; if ($element->hasAttributes()) { $attributes = $element->attributes; foreach ($attributes as $attribute) { $r .= " {$attribute->nodeName}='{$attribute->nodeValue}'"; } } $r .= '>'; $r .= innerHTML($element); $r .= "</{$element->nodeName}>"; } } return $r; }
$html = preg_replace('@^<' . $tag . '[^>]*>|</' . $tag . '>$@', '', $html); //update relative links // TODO: is is required? //return preg_replace('~href="(.*)_4.4/([^"]+).html"~', 'href="${1}4.4/${2}.php"', $html); return $html; } if (!isset($keyword) or $keyword == "") { $keyword = "eclipse 4.4, eclipse, new and noteworthy"; } $file = basename($App->getScriptName(), ".php") . '.html'; $doc = new DOMDocument(); $doc->loadhtmlfile($file); $body = $doc->getElementsByTagName('body')->item(0); $body = innerHTML($body); $title = $doc->getElementsByTagName('title')->item(0); $title = innerHTML($title); # # Begin: page-specific settings. Change these. $pageTitle = $title; $pageKeywords = $keyword; $pageAuthor = ""; $html = $body; //$html .='</div></div>'; $html = mb_convert_encoding($html, "HTML-ENTITIES", "auto"); $App->Promotion = FALSE; // if theme is not provided by caller, we specify "current one", explicitly hard-coded if (!isset($theme)) { $theme = "solstice"; } $App->AddExtraHtmlHeader('<link rel="stylesheet" href="default_style.css" charset="ISO-8859-1" type="text/css">'); $App->generatePage($theme, $Menu, $Nav, $pageAuthor, $pageKeywords, $pageTitle, $html);
echo "loading single view of " . strip_off_multiple_spaces(strip_tags($a->nodeValue)) . "\n"; $html = load_html($view, $single_view); @$docSingleView->loadHTML($html); $xpathSingleView = new DOMXpath($docSingleView); $h3 = $xpathSingleView->query('//div[contains(@class,"detailed")]/h3'); $h3 = $h3->item(0); $institution['name'] = strip_off_multiple_spaces($h3->nodeValue); $data = $xpathSingleView->query('//div[contains(@class,"detailed")]/div[contains(@class,"details")]/p/span'); for ($i = 0; $i < $data->length - 1; $i += 2) { $key = $data->item($i); $key = strip_off_multiple_spaces(strip_tags($key->nodeValue)); $value = $data->item($i + 1); if ($key == 'Internet') { $institution[$key] = html_entity_decode(strip_off_multiple_spaces($value->firstChild->getAttribute('href'))); } else { $institution[$key] = br2nl(strip_off_multiple_spaces(html_entity_decode(innerHTML($value), ENT_QUOTES, "UTF-8"))); } } //echo json_encode($institution) . "\n"; scraperwiki::save(array('id'), $institution); } } if ($max_single_view_pages < 1) { break; } if ($max_list_view_pages-- < 1) { break; } if ($more_pages) { echo "loading next page..." . "\n"; $params = ltrim(html_entity_decode($button->getAttribute('href')), "?");
public static function getSectionsHaveItems($sections) { $result_url = $base . 'Course/Results'; foreach ($sections as $section) { self::doRequest('CourseMaterials/AddSection?sectionId=' . urlencode($section['BId']), $sections[0]); } $doc = new DOMDocument(); @$doc->loadHTML(self::doRequest('Course/Results', $sections[0])); $finder = new DomXPath($doc); $ret = array(); foreach ($finder->query('//div[@class="course-info"]') as $course) { $tds = $finder->query('//td[@class="course-materials-description"]', $course); $items = array(); foreach ($tds as $td) { $item = array(); $item['Title'] = $finder->query('.//p[@class="title"]', $td)->item(0)->nodeValue; $info = explode('<br>', innerHTML($finder->query('.//p[@class="info"]', $td)->item(0))); foreach ($info as $subject) { list($key, $value) = array_map('trim', explode(':', strip_tags($subject))); if ($key == 'Edition') { //we need to get Edition and Publisher here.. $values = explode(',', $value); $item['edition'] = trim($values[0]); //$item['Year'] = preg_replace('([^0-9]*)', '', $values[1]); } else { if ($key == 'Author') { $item['author'] = $value; } else { if ($key == 'ISBN' && Isbn::validate(Isbn::clean($value))) { $item['isbn'] = $value; } } } } $required = strtolower($finder->query('.//a[@rel="/Help/RequirementHelp"]//strong', $td)->item(0)->nodeValue); $item['isComponent'] = $required == 'part of set'; if ($required == 'required') { $required = SectionHasItem::REQUIRED; } else { if ($required == 'recommended' || $required == 'optional') { $required = SectionHasItem::RECOMMENDED; } else { if ($required == 'neebo-suggested') { $required = SectionHasItem::BOOKSTORE_RECOMMENDED; } else { $required = SectionHasItem::REQUIRED; } } } $item['requiredStatus'] = $required; $prices = $finder->query('.//td[@class="course-product-price"]/label'); $priceList = array(); foreach ($prices as $price) { $priceList[] = preg_replace('([^0-9\\.]*)', '', $price->nodeValue); } $item['BNew'] = max($priceList); $items[] = $item; } list(, $sectionId) = explode('=', $finder->query('//h4/a', $course)->item(0)->getAttribute('href')); $ret[$sectionId] = self::processItems($items); } return $ret; }
} // Connect to hMailServer require 'HTTP/Request2.php'; $url = 'http://mail.ferryfair.com/PHPWebAdmin/standardAccountCreator.php'; $r = new Http_Request2($url); $r->setMethod(HTTP_Request2::METHOD_POST); $r->setHeader(array("Content-Type" => "application/x-www-form-urlencoded")); $r->addPostParameter(array('username' => $usrname, 'ePass' => $ePass, 'fullName' => $_POST['fullName'])); $r->addCookie('PHPSESSID', 'bkq0t2vf2n9898t4q83jje7bp7'); $r->addCookie('XDEBUG_SESSION', 'netbeans-xdebug'); $response = $r->send(); $page = $response->getBody(); $dd = new DOMDocument(); $dd->loadXML($page); $st = innerHTML($dd->getElementsByTagName('status')->item(0)); $accountId = innerHTML($dd->getElementsByTagName('accountId')->item(0)); if ($mkdir && $accountId) { $key = ftok('../../userFiles/' . $usrname . '/live.shm', 'c'); $shmId = shm_attach($key); $user['status'] = 0; $user['nickName'] = trim($nickName, "'"); $user['username'] = $usrname; $user['lat'] = time(); $user['uid'] = $lastUIndex; $spv = shm_put_var($shmId, $key, $user); $sd = shm_detach($shmId); echo "<status>success</status>"; } else { echo "<status>registeration successful but unable to create user directory. or update objectTable ~:|~ Contact administrator.</status>"; } } else {