当前位置: 首页>>代码示例>>PHP>>正文


PHP DOMDocument::getNode方法代码示例

本文整理汇总了PHP中DOMDocument::getNode方法的典型用法代码示例。如果您正苦于以下问题:PHP DOMDocument::getNode方法的具体用法?PHP DOMDocument::getNode怎么用?PHP DOMDocument::getNode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DOMDocument的用法示例。


在下文中一共展示了DOMDocument::getNode方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: zDigCheck

 /**
  * zDigCheck
  * @param DOMDocument $dom
  * @param string $tagid
  * @return boolean
  * @throws Exception\RuntimeException
  */
 private function zDigCheck($dom, $tagid = '')
 {
     $node = $dom->getNode($tagid, 0);
     if (empty($node)) {
         throw new Exception\RuntimeException("A tag < {$tagid} > não existe no XML!!");
     }
     if (!$this->zSignatureExists($dom)) {
         $msg = "O xml não contêm nenhuma assinatura para ser verificada.";
         throw new Exception\RuntimeException($msg);
     }
     //carregar o node em sua forma canonica
     $tagInf = $node->C14N(true, false, null, null);
     //calcular o hash sha1
     $hashValue = hash('sha1', $tagInf, true);
     //converter o hash para base64 para obter o digest do node
     $digestCalculado = base64_encode($hashValue);
     //pegar o digest informado no xml
     $digestInformado = $dom->getNodeValue('DigestValue');
     //compara os digests calculados e informados
     if ($digestCalculado != $digestInformado) {
         $msg = "O conteúdo do XML não confere com o Digest Value.\n\n                Digest calculado [{$digestCalculado}], digest informado no XML [{$digestInformado}].\n\n                O arquivo pode estar corrompido ou ter sido adulterado.";
         throw new Exception\RuntimeException($msg);
     }
     return true;
 }
开发者ID:JulianoAmaralChaves,项目名称:nfephp,代码行数:32,代码来源:Pkcs12.php

示例2: zReadDistDFeInteresse

 /**
  * zReadDistDFeInteresse
  * @param DOMDocument $dom
  * @param boolean $descompactar
  * @return array
  */
 protected static function zReadDistDFeInteresse($dom)
 {
     $aResposta = array('bStat' => false, 'versao' => '', 'cStat' => '', 'xMotivo' => '', 'dhResp' => '', 'ultNSU' => 0, 'maxNSU' => 0, 'aDoc' => array());
     $tag = $dom->getNode('retDistDFeInt');
     if (!isset($tag)) {
         return $aResposta;
     }
     $aDocZip = array();
     $docs = $tag->getElementsByTagName('docZip');
     foreach ($docs as $doc) {
         $xml = gzdecode(base64_decode($doc->nodeValue));
         $aDocZip[] = array('NSU' => $doc->getAttribute('NSU'), 'schema' => $doc->getAttribute('schema'), 'doc' => $xml);
     }
     $aResposta = array('bStat' => true, 'versao' => $tag->getAttribute('versao'), 'cStat' => $dom->getValue($tag, 'cStat'), 'xMotivo' => $dom->getValue($tag, 'xMotivo'), 'dhResp' => $dom->getValue($tag, 'dhResp'), 'ultNSU' => $dom->getValue($tag, 'ultNSU'), 'maxNSU' => $dom->getValue($tag, 'maxNSU'), 'aDoc' => $aDocZip);
     return $aResposta;
 }
开发者ID:eliasdanielmelo,项目名称:nfephp,代码行数:22,代码来源:ReturnNFe.php

示例3: zGetProt

 /**
  * zGetProt
  * @param DOMDocument $dom
  * @param DOMDocument $tag
  * @return array
  */
 private static function zGetProt($dom, $tag)
 {
     $aProt = array();
     $protMDFe = $tag->getElementsByTagName('protMDFe')->item(0);
     $infProt = $dom->getNode('infProt');
     if (empty($infProt)) {
         return $aProt;
     }
     $aProt = array('versao' => $protMDFe->getAttribute('versao'), 'tpAmb' => $dom->getValue($infProt, 'tpAmb'), 'verAplic' => $dom->getValue($infProt, 'verAplic'), 'chMDFe' => $dom->getValue($infProt, 'chMDFe'), 'dhRecbto' => $dom->getValue($infProt, 'dhRecbto'), 'nProt' => $dom->getValue($infProt, 'nProt'), 'digVal' => $dom->getValue($infProt, 'digVal'), 'cStat' => $dom->getValue($infProt, 'cStat'), 'xMotivo' => $dom->getValue($infProt, 'xMotivo'));
     return $aProt;
 }
开发者ID:JulianoAmaralChaves,项目名称:nfephp,代码行数:17,代码来源:ReturnMDFe.php


注:本文中的DOMDocument::getNode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。