本文整理汇总了PHP中DOMNode::getElementsByTagName方法的典型用法代码示例。如果您正苦于以下问题:PHP DOMNode::getElementsByTagName方法的具体用法?PHP DOMNode::getElementsByTagName怎么用?PHP DOMNode::getElementsByTagName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DOMNode
的用法示例。
在下文中一共展示了DOMNode::getElementsByTagName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __collectGroup
protected function __collectGroup(DOMDocument $v9a09b4dfda82e3e665e31092d1c3ec8d, DOMNode $v1471e4e05a4db95d353cc867fe317314, DOMNode $vdb0f6f37ebeb6ea09489124345af2a45)
{
$v3d788fa62d7c185a1bee4c9147ee1091 = new DOMXPath($v9a09b4dfda82e3e665e31092d1c3ec8d);
$vb8d7f0a7b1f89a0e2689069b9ead837d = $vdb0f6f37ebeb6ea09489124345af2a45->getElementsByTagName("Ид");
$v00655e48bd78b9fefe2ba39b753dd932 = $vdb0f6f37ebeb6ea09489124345af2a45->getElementsByTagName("Наименование");
$vb80bb7740288fda1f201890375a60c8f = $vb8d7f0a7b1f89a0e2689069b9ead837d->item(0)->nodeValue;
$vb068931cc450442b63f5b3d276ea4297 = $v00655e48bd78b9fefe2ba39b753dd932->item(0)->nodeValue;
$vc772070e479ef7642e1f6b1620b703ab = $v3d788fa62d7c185a1bee4c9147ee1091->evaluate(".//Группа[Ид='{$vb80bb7740288fda1f201890375a60c8f}']", $v1471e4e05a4db95d353cc867fe317314);
if ($vc772070e479ef7642e1f6b1620b703ab instanceof DOMNodeList && $vc772070e479ef7642e1f6b1620b703ab->length) {
return $vc772070e479ef7642e1f6b1620b703ab->item(0);
}
$v1722ade329f7d0765de2a5d5cf04b3e6 = $v9a09b4dfda82e3e665e31092d1c3ec8d->createElement('Группа');
$v1722ade329f7d0765de2a5d5cf04b3e6->appendChild($v9a09b4dfda82e3e665e31092d1c3ec8d->createElement('Ид', $vb80bb7740288fda1f201890375a60c8f));
$v1722ade329f7d0765de2a5d5cf04b3e6->appendChild($v9a09b4dfda82e3e665e31092d1c3ec8d->createElement('Наименование', $vb068931cc450442b63f5b3d276ea4297));
$vd0e45878043844ffc41aac437e86b602 = $vdb0f6f37ebeb6ea09489124345af2a45->parentNode ? $vdb0f6f37ebeb6ea09489124345af2a45->parentNode->parentNode : false;
if ($vd0e45878043844ffc41aac437e86b602 && $vd0e45878043844ffc41aac437e86b602->nodeName == "Группа") {
$v8040a7de679c140285d7b0ca689dadc5 = $this->__collectGroup($v9a09b4dfda82e3e665e31092d1c3ec8d, $v1471e4e05a4db95d353cc867fe317314, $vd0e45878043844ffc41aac437e86b602);
$vecc14ae322be7f2622dee4a101209ee9 = $v8040a7de679c140285d7b0ca689dadc5->childNodes->item(2);
if (!$vecc14ae322be7f2622dee4a101209ee9) {
$vecc14ae322be7f2622dee4a101209ee9 = $v8040a7de679c140285d7b0ca689dadc5->appendChild($v9a09b4dfda82e3e665e31092d1c3ec8d->createElement("Группы"));
}
$vecc14ae322be7f2622dee4a101209ee9->appendChild($v1722ade329f7d0765de2a5d5cf04b3e6);
} else {
$v1471e4e05a4db95d353cc867fe317314->appendChild($v1722ade329f7d0765de2a5d5cf04b3e6);
}
return $v1722ade329f7d0765de2a5d5cf04b3e6;
}
示例2: getChNFe
/**
* Retorna a chave de 44 caracteres da nfe.
*
* @return string
*/
public function getChNFe()
{
if ($this->isError()) {
return '';
}
return $this->infProt->getElementsByTagName('chNFe')->item(0)->textContent;
}
示例3: loadFromXml
protected function loadFromXml(DOMNode $elem)
{
$attr = $elem->attributes->getNamedItem('type');
if ($attr != null) {
$this->type = $attr->nodeValue;
} else {
$this->type = self::TYPE_PERSON;
}
$elems = $elem->getElementsByTagName('first_name');
if ($elems->length == 1) {
$this->firstName = urldecode($elems->item(0)->nodeValue);
}
$elems = $elem->getElementsByTagName('last_name');
if ($elems->length == 1) {
$this->lastName = urldecode($elems->item(0)->nodeValue);
}
$elems = $elem->getElementsByTagName('address');
if ($elems->length == 1) {
$this->address = urldecode($elems->item(0)->nodeValue);
}
$elems = $elem->getElementsByTagName('email');
if ($elems->length == 1) {
$this->email = urldecode($elems->item(0)->nodeValue);
}
$elems = $elem->getElementsByTagName('mobile_phone');
if ($elems->length == 1) {
$this->mobilePhone = urldecode($elems->item(0)->nodeValue);
}
}
开发者ID:alexandrei892,项目名称:mobilpay-card-gateway-for-woocommerce,代码行数:29,代码来源:class-mobilpay-address.php
示例4: createNode
function createNode(DOMDocument $targetdoc, DOMNode $targetnode, DOMNode $entry, $with_content = true)
{
$a = $targetdoc->createElement('a');
$targetnode->appendChild($a);
$a->setAttribute('href', $entry->getElementsByTagName('id')->item(0)->nodeValue);
$a->appendChild($targetdoc->createElement('b', date('Y-m-d H:i:s', strtotime($entry->getElementsByTagName('updated')->item(0)->nodeValue)) . ': '));
$a->appendChild($targetdoc->createTextNode($entry->getElementsByTagName('title')->item(0)->nodeValue));
if ($with_content && ($contents = $entry->getElementsByTagName('content')) && $contents->length) {
$div = $targetdoc->createElement('div');
$targetnode->appendChild($div);
$div->appendChild($targetdoc->importNode($contents->item(0), true));
}
}
示例5: matchXmlStructure
/**
* @param $xml
* @return bool
*/
public function matchXmlStructure($xml)
{
$xml = XmlUtils::toXml($xml);
$root = $xml->firstChild;
$els = $this->xml->getElementsByTagName($root->nodeName);
if (empty($els)) {
throw new ElementNotFound($root->nodeName, 'Element');
}
$matches = false;
foreach ($els as $node) {
$matches |= $this->matchForNode($root, $node);
}
return $matches;
}
示例6: unserializeContentClassAttribute
/**
* Unserialize contentclass attribute
*
* @param eZContentClassAttribute $classAttribute
* @param DOMNode $attributeNode
* @param DOMNode $attributeParametersNode
*/
function unserializeContentClassAttribute($classAttribute, $attributeNode, $attributeParametersNode)
{
$defaultZoneLayout = $attributeParametersNode->getElementsByTagName('default-layout')->item(0)->textContent;
if ($defaultZoneLayout !== false) {
$classAttribute->setAttribute(self::DEFAULT_ZONE_LAYOUT_FIELD, $defaultZoneLayout);
}
}
示例7: applyStyle
/**
* Apply style information to object
* If object has no style information yet, then create new style node
* If object style information is similar to other object's style info, then apply the same style name
* And if object old style information was not shared with other objects then delete old style info
* Else leave old style info
* Else just add new style description
*
* @param string $style_name
* @param string $name
* @param mixed $value
* @param OpenDocument_StyledElement $object
* @return string $style_name
*/
public function applyStyle($style_name, $name, $value, OpenDocument_StyledElement $object)
{
//check if other nodes have the same style name
$nodes = $this->cursor->getElementsByTagName('*');
$count = 0;
foreach ($nodes as $node) {
if ($node->hasAttributeNS(self::NS_TEXT, 'style-name') && $node->getAttributeNS(self::NS_TEXT, 'style-name') == $style_name) {
$count++;
if ($count > 1) {
break;
}
}
}
$generate = false;
//get style node
if ($count > 1) {
$style = $this->getStyleNode($style_name)->cloneNode(true);
$this->styles->appendChild($style);
$generate = true;
$style_name = uniqid('tmp');
//$object->generateStyleName();
$style->setAttributeNS(self::NS_STYLE, 'name', $style_name);
} else {
$style = $this->getStyleNode($style_name);
}
if (empty($style)) {
if (empty($style_name)) {
$generate = true;
$style_name = uniqid('tmp');
}
$style = $this->contentDOM->createElementNS(self::NS_STYLE, 'style');
$style->setAttributeNS(self::NS_STYLE, 'name', $style_name);
$style->setAttributeNS(self::NS_STYLE, 'family', 'paragraph');
$style->setAttributeNS(self::NS_STYLE, 'parent-style-name', 'Standard');
$this->styles->appendChild($style);
}
$nodes = $style->getElementsByTagNameNS(self::NS_STYLE, 'text-properties');
if ($nodes->length) {
$text_properties = $nodes->item(0);
} else {
$text_properties = $this->contentDOM->createElementNS(self::NS_STYLE, 'text-properties');
$style->appendChild($text_properties);
}
$text_properties->setAttribute($name, $value);
//find alike style
$nodes = $this->styles->getElementsByTagNameNS(self::NS_STYLE, 'style');
foreach ($nodes as $node) {
if (!$style->isSameNode($node) && $this->compareChildNodes($style, $node)) {
$style->parentNode->removeChild($style);
return $node->getAttributeNS(self::NS_STYLE, 'name');
}
}
if ($generate) {
$style_name = $object->generateStyleName();
$style->setAttributeNS(self::NS_STYLE, 'name', $style_name);
}
return $style->getAttributeNS(self::NS_STYLE, 'name');
}
示例8: getFirstElementByTagName
/**
* Returns the first $subnode occurence of a $node.
* The subnode is identified by its name.
*
* @param DOMNode $node
* @param string $subnode_name
* @return DOMNode
*/
public static function getFirstElementByTagName($node, $subnode_name)
{
$nodes = $node->getElementsByTagName($subnode_name);
if ($nodes->length > 0) {
return $nodes->item(0);
} else {
return null;
}
}
示例9: getNodesName
/**
* Return array of descendant DOMNode of $node with tagName equals to $name
*
* @param DOMNode $node to starts with
* @param string $name of descendant
*
* @return array of descendant DOMNode with tagName equals to $name
*/
public static function getNodesName($node, $name)
{
if (strpos($name, ':') !== false) {
list(, $localname) = explode(':', $name);
$nodes = $node->getElementsByTagNameNS('*', $localname);
} else {
$nodes = $node->getElementsByTagName($name);
}
return self::filterNodeListByName($nodes, $name);
}
示例10: getPropertyFromNode
/**
* Get property from nide
*
* @param DOMNode $node Node
* @param String $tagName tag name
* @param Boolean $nullable property can be null
*
* @return String description
*
*/
public static function getPropertyFromNode(\DOMNode $node, $tagName, $nullable = true)
{
$elements = $node->getElementsByTagName($tagName);
if ($elements->length == 0) {
if (!$nullable) {
throw new MetadataException(sprintf('%s : hydratation error with "%s" node.', get_called_class(), $tagName));
}
return null;
}
$value = $elements->item(0)->nodeValue;
return $value == 'false' ? false : $value;
}
示例11: __construct
/**
* Create a MARC Data Field
*
* @param \DOMNode $objNode
*/
public function __construct(\DOMNode $objNode = null)
{
if ($objNode != null) {
$this->tag = $objNode->getAttribute("tag");
$this->ind1 = $objNode->getAttribute("ind1");
$this->ind2 = $objNode->getAttribute("ind2");
foreach ($objNode->getElementsByTagName("subfield") as $objSubfield) {
$objMarcSubField = new SubField($objSubfield);
array_push($this->_subfields, $objMarcSubField);
}
}
}
示例12: loadFromXml
protected function loadFromXml(DOMNode $elem)
{
$attr = $elem->attributes->getNamedItem('currency');
if ($attr == null) {
throw new Exception('Mobilpay_Payment_Invoice::loadFromXml failed; currency attribute missing', self::ERROR_LOAD_FROM_XML_CURRENCY_ATTR_MISSING);
}
$this->currency = $attr->nodeValue;
$attr = $elem->attributes->getNamedItem('amount');
if ($attr != null) {
$this->amount = $attr->nodeValue;
}
$attr = $elem->attributes->getNamedItem('installments');
if ($attr != null) {
$this->installments = $attr->nodeValue;
}
$attr = $elem->attributes->getNamedItem('selected_installments');
if ($attr != null) {
$this->selectedInstallments = $attr->nodeValue;
}
$elems = $elem->getElementsByTagName('details');
if ($elems->length == 1) {
$this->details = urldecode($elems->item(0)->nodeValue);
}
$elems = $elem->getElementsByTagName('contact_info');
if ($elems->length == 1) {
$addrElem = $elems->item(0);
$elems = $addrElem->getElementsByTagName('billing');
if ($elems->length == 1) {
$this->billingAddress = new Mobilpay_Payment_Address($elems->item(0));
}
$elems = $addrElem->getElementsByTagName('shipping');
if ($elems->length == 1) {
$this->shippingAddress = new Mobilpay_Payment_Address($elems->item(0));
}
}
}
示例13: parseTable
/**
* @param DOMElement|DOMNode $table
* @param array $range
* @return array
*/
protected function parseTable($table, $range = null)
{
$array = array();
foreach ($table->getElementsByTagName('tr') as $row => $tr) {
if ($range) {
foreach ($range as $i) {
$array[$row][] = $tr->getElementsByTagName('td')->item($i)->textContent;
}
} else {
foreach ($tr->getElementsByTagName('td') as $td) {
$array[$row][] = $td->textContent;
}
}
}
return $array;
}
示例14: configure
public function configure($parent, $configContext, DOMNode $documentElement)
{
$this->setORBConfig($configContext);
$section = $documentElement->getElementsByTagName("services")->item(0);
// check required !
$this->m_configNode = $section;
foreach ($section->childNodes as $element) {
if (!$element instanceof DOMElement) {
continue;
}
$nameElements = $element->getElementsByTagName("name");
$serviceName = trim($nameElements->item(0)->nodeValue);
$idElements = $element->getElementsByTagName("serviceId");
$serviceId = trim($idElements->item(0)->nodeValue);
ORBConfig::getInstance()->getServiceRegistry()->_addMapping($serviceName, $serviceId, array());
}
}
示例15: getItem
function getItem(\DOMNode $itemDomNode)
{
$item = new \stdClass();
$item->title = $itemDomNode->getElementsByTagName('title')->item(0)->firstChild->data;
$item->link = $itemDomNode->getElementsByTagName('link')->item(0)->firstChild->data;
$item->description = $itemDomNode->getElementsByTagName('description')->item(0)->firstChild->data;
$authorText = $itemDomNode->getElementsByTagName('author')->item(0)->firstChild->data;
$arr = explode(' ', trim($authorText));
$item->authorEmail = trim($arr[0]);
$item->guid = $itemDomNode->getElementsByTagName('guid')->item(0)->firstChild->data;
$item->pubDate = $itemDomNode->getElementsByTagName('pubDate')->item(0)->firstChild->data;
$item->viaUrl = $itemDomNode->getElementsByTagNameNS('http://www.editoreye.com/rss/via', 'link')->item(0)->getAttribute('url');
$item->via = $itemDomNode->getElementsByTagNameNS('http://www.editoreye.com/rss/via', 'link')->item(0)->getAttribute('name');
$item->authorName = $itemDomNode->getElementsByTagNameNS('http://purl.org/dc/elements/1.1/', 'creator')->item(0)->firstChild->data;
$item->content = $itemDomNode->getElementsByTagName('content')->item(0)->firstChild->data;
return $item;
}