本文整理汇总了PHP中DOMElement::getElementsByTagName方法的典型用法代码示例。如果您正苦于以下问题:PHP DOMElement::getElementsByTagName方法的具体用法?PHP DOMElement::getElementsByTagName怎么用?PHP DOMElement::getElementsByTagName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DOMElement
的用法示例。
在下文中一共展示了DOMElement::getElementsByTagName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createMap
/**
* @param callable $rowParseCallback
* @param callable $cellParseCallback
* @return void
*/
public function createMap(\Closure $rowParseCallback = null, \Closure $cellParseCallback = null)
{
// First, dos ome basic cleanup
$this->cleanupTable();
// Then, get all rows and parse!
$trs = $this->table->getElementsByTagName('tr');
if ($trs instanceof \DOMNodeList && $trs->length > 0) {
for ($tri = 0, $rowGroupi = 0; $tri < $trs->length; $rowGroupi++) {
/** @var \DOMElement $tr */
$tr = $trs->item($tri);
$this->rowOffsets[$rowGroupi] = array('firstRow' => $tri);
$this->rowCellMap[$rowGroupi] = array();
$this->rowGroups[$rowGroupi] = array();
$rowSpan = 1;
foreach ($tr->childNodes as $child) {
/** @var $child \DOMElement */
if ($child->hasAttribute('rowspan') && (int) $child->getAttribute('rowspan') > $rowSpan) {
$rowSpan = (int) $child->getAttribute('rowspan');
}
}
$this->parseRowGroup($this->rowCellMap[$rowGroupi], $this->rowGroups[$rowGroupi], $rowSpan, $tr, $rowParseCallback, $cellParseCallback);
$tri += $rowSpan;
$this->rowOffsets[$rowGroupi]['lastRow'] = $tri > 0 ? $tri - 1 : $tri;
}
}
}
示例2: __construct
/**
* Creates a new CqOption.
*
* @param DOMElement $node
* containing the option definition
* @param CqQuestionInterface $context
* CqQuestionInterface The question or other object that the mapping can query for
* things like the current answer, draggables, hotspots and the parsing of
* html.
*/
public function __construct(DOMElement $node, $context)
{
foreach ($node->getElementsByTagName('choice') as $choice) {
$this->text .= cq_get_text_content($choice, $context);
}
foreach ($node->getElementsByTagName('description') as $description) {
$this->description .= cq_get_text_content($description, $context);
}
foreach ($node->getElementsByTagName('feedback') as $fb) {
$this->feedback[] = CqFeedback::newCqFeedback($fb, $context);
}
foreach ($node->getElementsByTagName('feedbackunselected') as $fb) {
$this->feedbackUnselected[] = CqFeedback::newCqFeedback($fb, $context);
}
$attribs = $node->attributes;
$item = $attribs->getNamedItem('correct');
if ($item !== NULL) {
$this->correct = (int) $item->value;
}
$item = $attribs->getNamedItem('identifier');
if ($item === NULL) {
$item = $attribs->getNamedItem('id');
}
if ($item === NULL) {
$item = $attribs->getNamedItem('name');
}
if ($item !== NULL) {
$this->identifier = $item->nodeValue;
}
}
示例3: getValue
/**
* getValue
* @param DOMElement $node
* @param string $name
* @return string
*/
public function getValue($node, $name)
{
if (empty($node)) {
return '';
}
$texto = !empty($node->getElementsByTagName($name)->item(0)->nodeValue) ? $node->getElementsByTagName($name)->item(0)->nodeValue : '';
return html_entity_decode($texto, ENT_QUOTES, 'UTF-8');
}
示例4: getOptionalField
private function getOptionalField($fieldName, $attributeName = null)
{
$value = '';
$tag = $this->currentVideo->getElementsByTagName($fieldName);
if ($tag->length) {
$value = is_null($attributeName) ? $tag->item(0)->textContent : $tag->item(0)->getAttribute($attributeName);
}
return $value;
}
示例5: _downloadTestData
/**
* テストデータをダウンロードする
*
* @param DOMElement $item
* @return string
**/
private function _downloadTestData($item)
{
$url = $item->getElementsByTagName('link')->item(0)->nodeValue;
if ($url === '') {
$url = $item->getElementsByTagName('link')->item(0)->getAttribute('href');
}
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($curl);
curl_close($curl);
return $result;
}
示例6: applyXMLElement
public function applyXMLElement(\DOMElement $element)
{
$this->_alpha2 = $element->getAttribute('code');
$listXMLNode = $element->getElementsByTagName('iso_3166_subset');
// check if country has sub divisions
if (!$listXMLNode->length) {
return;
}
// get sub division type
$this->_subDivisionName = $listXMLNode->item(0)->getAttribute('type');
foreach ($element->getElementsByTagName('iso_3166_2_entry') as $element) {
$this->_list[$element->getAttribute('code')] = $element->getAttribute('name');
}
}
示例7: convertXMLToRelation
/**
* Converts a DOMElement item to a Zotero_Relation object
*
* @param DOMElement $xml Relation data as DOM element
* @param Integer $libraryID
* @return Zotero_Relation Zotero relation object
*/
public static function convertXMLToRelation(DOMElement $xml, $userLibraryID)
{
$relation = new Zotero_Relation();
$libraryID = $xml->getAttribute('libraryID');
if ($libraryID) {
$relation->libraryID = $libraryID;
} else {
$relation->libraryID = $userLibraryID;
}
$relation->subject = $xml->getElementsByTagName('subject')->item(0)->nodeValue;
$relation->predicate = $xml->getElementsByTagName('predicate')->item(0)->nodeValue;
$relation->object = $xml->getElementsByTagName('object')->item(0)->nodeValue;
return $relation;
}
示例8: appendComment
public function appendComment(DOMElement $changeset, array $row)
{
$dom_node_list = $changeset->getElementsByTagName('comments');
$comments_node = $dom_node_list->item(0);
$this->all_comments[$row['id']] = $comments_node;
$comments_node->appendChild($this->createCommentNode($row));
}
示例9: handleImages
/**
*
* @param DOMElement $dom
* @return array
*/
private function handleImages($dom, $url)
{
$images = array();
$parts = parse_url($url);
$savedImages = array();
$imgElements = $dom->getElementsByTagName('img');
foreach ($imgElements as $img) {
$src = $img->getAttribute("src");
$is_root = false;
if (substr($src, 0, 1) == "/") {
$is_root = true;
}
$parsed = parse_url($src);
if (!isset($parsed["host"])) {
if ($is_root) {
$src = http_build_url($url, $parsed, HTTP_URL_REPLACE);
} else {
$src = http_build_url($url, $parsed, HTTP_URL_JOIN_PATH);
}
}
$img->setAttribute("src", "");
if (isset($savedImages[$src])) {
$img->setAttribute("recindex", $savedImages[$src]);
} else {
$image = ImageHandler::DownloadImage($src);
if ($image !== false) {
$images[$this->imgCounter] = new FileRecord(new Record($image));
$img->setAttribute("recindex", $this->imgCounter);
$savedImages[$src] = $this->imgCounter;
$this->imgCounter++;
}
}
}
return $images;
}
示例10: unserializeContentClassAttribute
/**
* Unserialize contentclass attribute
*
* @param eZContentClassAttribute $classAttribute
* @param DOMElement $attributeNode
* @param DOMElement $attributeParametersNode
*/
function unserializeContentClassAttribute($classAttribute, $attributeNode, $attributeParametersNode)
{
$defaultZoneLayoutItem = $attributeParametersNode->getElementsByTagName('default-layout')->item(0);
if ($defaultZoneLayoutItem !== null && $defaultZoneLayoutItem->textContent !== false) {
$classAttribute->setAttribute(self::DEFAULT_ZONE_LAYOUT_FIELD, $defaultZoneLayoutItem->textContent);
}
}
示例11: extractImages
/**
* Extract <img> elements
*
* @param \DOMElement $html
* @param Bag $bag
* @param null|string $domain
*/
protected static function extractImages(\DOMElement $html, Bag $bag, $domain = null)
{
foreach ($html->getElementsByTagName('img') as $img) {
self::addByAttribute($img, 'src', $html, $bag, $domain);
self::addByAttribute($img, 'data-src', $html, $bag, $domain);
}
}
示例12: update
function update(DOMElement $item)
{
$title = $item->getElementsByTagName('title');
$description = $item->getElementsByTagName('description');
$pubDate = $item->getElementsByTagName('pubDate');
$link = $item->getElementsByTagName('link');
$nodeEnclosure = $item->getElementsByTagName('enclosure');
$this->titre = $title->item(0)->textContent;
$this->description = $description->item(0)->textContent;
$this->date = $pubDate->item(0)->textContent;
$this->url = $link->item(0)->textContent;
if ($nodeEnclosure != NULL) {
$this->image = $nodeEnclosure->item(0)->attributes->getNamedItem('url')->nodeValue;
} else {
$this->image = "default";
}
}
示例13: configurationFromXML
/**
* Generate node configuration from XML representation.
*
* @param DOMElement $element
* @return array
* @ignore
*/
public static function configurationFromXML(DOMElement $element)
{
$configuration = array();
foreach ($element->getElementsByTagName('variable') as $variable) {
$configuration[] = $variable->getAttribute('name');
}
return $configuration;
}
示例14: configurationFromXML
/**
* Generate node configuration from XML representation.
*
* @param DOMElement $element
* @return array
* @ignore
*/
public static function configurationFromXML(DOMElement $element)
{
$configuration = array();
foreach ($element->getElementsByTagName('variable') as $variable) {
$configuration[$variable->getAttribute('name')] = ezcWorkflowDefinitionStorageXml::xmlToVariable(ezcWorkflowUtil::getChildNode($variable));
}
return $configuration;
}
示例15: getVocations
/**
* Returns list of vocations that are allowed to learn this spell.
*
* @return array List of vocation names.
* @throws DOMException On DOM operation error.
*/
public function getVocations()
{
$vocations = array();
foreach ($this->element->getElementsByTagName('vocation') as $vocation) {
$vocations[] = $vocation->getAttribute('name');
}
return $vocations;
}