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


PHP DOMDocument::getElementsByTagNameNS方法代码示例

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


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

示例1: foreach

 function decodeGz64()
 {
     $contentNodes = $this->xpath->query("//content");
     foreach ($contentNodes as $contentNode) {
         if ($contentNode->getAttribute("contentType") == "application/x-gzip" && $contentNode->getAttribute('contentTransferEncoding') == "base64") {
             $contentDOM = new \DOMDocument();
             $contentDOM->loadXML(gzdecode(base64_decode($contentNode->nodeValue)));
             $xmlns = "http://schemas.ogf.org/nml/2013/05/base#";
             $tagName = "Topology";
             foreach ($contentDOM->getElementsByTagNameNS($xmlns, $tagName) as $netNode) {
                 $node = $this->xml->importNode($netNode, true);
                 $contentNode->nodeValue = "";
                 $contentNode->removeAttribute("contentType");
                 $contentNode->removeAttribute('contentTransferEncoding');
                 $contentNode->appendChild($node);
             }
             $xmlns = "http://schemas.ogf.org/nsi/2014/02/discovery/nsa";
             $tagName = "nsa";
             foreach ($contentDOM->getElementsByTagNameNS($xmlns, $tagName) as $nsaNode) {
                 $node = $this->xml->importNode($nsaNode, true);
                 $contentNode->nodeValue = "";
                 $contentNode->removeAttribute("contentType");
                 $contentNode->removeAttribute('contentTransferEncoding');
                 $contentNode->appendChild($node);
             }
         }
     }
 }
开发者ID:ufrgs-hyman,项目名称:proxy-agg,代码行数:28,代码来源:NSIProxy.php

示例2: createXMLNode

	/**
	 * Cria o nó XML que representa o objeto ou conjunto de objetos na composição
	 * @return	string
	 * @see		Cielo::createXMLNode()
	 * @throws	BadMethodCallException Se a URL de retorno não tiver sido especificada
	 * @throws	BadMethodCallException Se os dados do pedido não tiver sido especificado
	 */
	public function createXMLNode() {
		if (  !empty( $this->tid ) ) {
			$dom = new DOMDocument( '1.0' , 'UTF-8' );
			$dom->loadXML( parent::createXMLNode() );
			$dom->encoding = 'UTF-8';

			$namespace = $this->getNamespace();
			$query = $dom->getElementsByTagNameNS( $namespace , $this->getRootNode() )->item( 0 );
			$EcData = $dom->getElementsByTagNameNS( $namespace , 'dados-ec' )->item( 0 );

			if ( $EcData instanceof DOMElement ) {
				$tid = $dom->createElement( 'tid' , $this->tid );
				$query->insertBefore( $tid , $EcData );

				if (  !is_null( $this->value ) ) {
					$value = $dom->createElement( 'valor' , $this->value );
					$query->insertBefore( $value , $EcData );
				}

				if (  !is_null( $this->annex ) ) {
					$annex = $dom->createElement( 'anexo' );
					$query->insertBefore( $annex , $EcData );
				}
			} else {
				throw new BadMethodCallException( 'O nó dados-ec precisa ser informado.' );
			}

			return $dom->saveXML();
		} else {
			throw new BadMethodCallException( 'O ID da transação deve ser informado.' );
		}
	}
开发者ID:netojoaobatista,项目名称:cielo,代码行数:39,代码来源:CaptureRequest.php

示例3: _handleError

 /**
  * Private Error handler logic
  */
 private function _handleError(&$result, &$headers, &$xmlPayLoad, &$HTTPHeaders)
 {
     // Fallback error messages
     $ErrorCode = 'Errorcode unavailable as there was no content received from the server.';
     $ErrorMsg = 'Errormessage unavailable as there was no content received from the server.';
     if (strlen($result) > 0) {
         $xmlError = new \DOMDocument();
         $xmlError->loadXML($result);
         try {
             $ErrorCode = $xmlError->getElementsByTagNameNS('http://config.services.bol.com/schemas/serviceerror-1.5.xsd', 'errorCode');
             $ErrorCode = $ErrorCode->item(0)->nodeValue;
             $ErrorMsg = $xmlError->getElementsByTagNameNS('http://config.services.bol.com/schemas/serviceerror-1.5.xsd', 'errorMessage');
             $ErrorMsg = $ErrorMsg->item(0)->nodeValue;
         } catch (Exception $e) {
             echo 'An error occurred while parsing the XML Error Message. Raw XML printed below<br>';
         }
     }
     // @TODO: Dit netjes oplossen. Mooie custom Exception definieren en deze data in stoppen.
     echo 'XML Payload: "' . (strlen($xmlPayLoad) > 0 ? $xmlPayLoad : 'No XML data received, so there\'s nothing to parse!') . "\"\n<br>";
     echo "<pre>Curl header info:\n";
     print_r($headers);
     echo "HTTP Headers:\n";
     print_r($HTTPHeaders);
     echo "</pre>";
     if ($this->debug) {
         trigger_error($ErrorCode . ' - ' . $ErrorMsg, E_USER_ERROR);
     } else {
         throw new \Exception($ErrorCode . ' - ' . $ErrorMsg);
     }
 }
开发者ID:avido,项目名称:bol.com-plaza-api-clients,代码行数:33,代码来源:Comms.php

示例4: testValidateSchema

 /**
  * @dataProvider dataValidateSchemaFiles
  * @param string $file
  */
 public function testValidateSchema($file)
 {
     $found = false;
     $dom = new \DOMDocument('1.0', 'UTF-8');
     $dom->load($file);
     $dbalElements = $dom->getElementsByTagNameNS("http://symfony.com/schema/dic/doctrine", "config");
     if ($dbalElements->length) {
         $dbalDom = new \DOMDocument('1.0', 'UTF-8');
         $dbalNode = $dbalDom->importNode($dbalElements->item(0));
         $dbalDom->appendChild($dbalNode);
         $ret = $dbalDom->schemaValidate(__DIR__ . "/../../Resources/config/schema/doctrine-1.0.xsd");
         $this->assertTrue($ret, "DoctrineBundle Dependency Injection XMLSchema did not validate this XML instance.");
         $found = true;
     }
     $ormElements = $dom->getElementsByTagNameNS("http://symfony.com/schema/dic/doctrine", "config");
     if ($ormElements->length) {
         $ormDom = new \DOMDocument('1.0', 'UTF-8');
         $ormNode = $ormDom->importNode($ormElements->item(0));
         $ormDom->appendChild($ormNode);
         $ret = $ormDom->schemaValidate(__DIR__ . "/../../Resources/config/schema/doctrine-1.0.xsd");
         $this->assertTrue($ret, "DoctrineBundle Dependency Injection XMLSchema did not validate this XML instance.");
         $found = true;
     }
     $this->assertTrue($found, "Neither <doctrine:orm> nor <doctrine:dbal> elements found in given XML. Are namespaces configured correctly?");
 }
开发者ID:robertowest,项目名称:CuteFlow-V4,代码行数:29,代码来源:XMLSchemaTest.php

示例5: decodeStream

 function decodeStream($request, $stream)
 {
     $dom = new DOMDocument("1.0");
     $success = $dom->loadXML($this->stripHTTPHeader($stream));
     $this->DOMDocument = $dom;
     if ($success && !empty($dom)) {
         // check for fault
         $response = $dom->getElementsByTagNameNS(eZSOAPEnvelope::ENV, 'Fault');
         if ($response->length == 1) {
             $this->IsFault = 1;
             foreach ($dom->getElementsByTagName("faultstring") as $faultNode) {
                 $this->FaultString = $faultNode->textContent;
                 break;
             }
             foreach ($dom->getElementsByTagName("faultcode") as $faultNode) {
                 $this->FaultCode = $faultNode->textContent;
                 break;
             }
             return;
         }
         // get the response
         $response = $dom->getElementsByTagNameNS($request->ns(), $request->name() . "Response");
         /* Some protocols do not use namespaces, and do not work with an empty namespace.
            So, if we get no response, try again without namespace.
            */
         if ($response->length == 0) {
             $response = $dom->getElementsByTagName($request->name() . "Response");
         }
         $response = $response->item(0);
         if (!empty($response)) {
             /* Cut from the SOAP spec:
                             The method response is viewed as a single struct containing an accessor
                             for the return value and each [out] or [in/out] parameter.
                             The first accessor is the return value followed by the parameters
                             in the same order as in the method signature.
             
                             Each parameter accessor has a name corresponding to the name
                             of the parameter and type corresponding to the type of the parameter.
                             The name of the return value accessor is not significant.
                             Likewise, the name of the struct is not significant.
                             However, a convention is to name it after the method name
                             with the string "Response" appended.
                             */
             $responseAccessors = $response->getElementsByTagName('return');
             if ($responseAccessors->length > 0) {
                 $returnObject = $responseAccessors->item(0);
                 $this->Value = $this->decodeDataTypes($returnObject);
             }
         } else {
             eZDebug::writeError("Got error from server");
         }
     } else {
         eZDebug::writeError("Could not process XML in response");
     }
 }
开发者ID:CG77,项目名称:ezpublish-legacy,代码行数:55,代码来源:ezsoapresponse.php

示例6: isValid

 /**
  * Parses a validation response from a CAS server to see if the returning CAS request is valid
  *
  * @param string $results		xml or plain text response from cas server
  * @return bool						true if valid, false otherwise
  * @exception 						throws exception if cannot parse response or invalid version
  */
 private function isValid()
 {
     // values from the request
     $ticket = $this->request->getParam("ticket");
     // configuration settings
     $configCasValidate = $this->registry->getConfig("CAS_VALIDATE", true);
     $configCasValidate = rtrim($configCasValidate, '/');
     // figure out which type of response this is based on the service url
     $arrURL = explode("/", $configCasValidate);
     $service = array_pop($arrURL);
     // now get it!
     $url = $configCasValidate . "?ticket=" . $ticket . "&service=" . urlencode($this->validate_url);
     $http_client = Factory::getHttpClient();
     $http_client->setUri($url);
     $results = $http_client->send()->getBody();
     // validate is plain text
     if ($service == "validate") {
         $message_array = explode("\n", $results);
         if (count($message_array) >= 2) {
             if ($message_array[0] == "yes") {
                 return $message_array[1];
             }
         } else {
             throw new \Exception("Could not parse CAS validation response.");
         }
     } elseif ($service == "serviceValidate" || $service == "proxyValidate") {
         // these are XML based
         $xml = new \DOMDocument();
         $xml->loadXML($results);
         $cas_namespace = "http://www.yale.edu/tp/cas";
         $user = $xml->getElementsByTagNameNS($cas_namespace, "user")->item(0);
         $failure = $xml->getElementsByTagNameNS($cas_namespace, "authenticationFailure")->item(0);
         if ($user != null) {
             if ($user->nodeValue != "") {
                 return $user->nodeValue;
             } else {
                 throw new \Exception("CAS validation response missing username value");
             }
         } elseif ($failure != null) {
             // see if error, rather than failed authentication
             if ($failure->getAttribute("code") == "INVALID_REQUEST") {
                 throw new \Exception("Invalid request to CAS server: " . $failure->nodeValue);
             }
         } else {
             throw new \Exception("Could not parse CAS validation response.");
         }
     } else {
         throw new \Exception("Unsupported CAS version.");
     }
     // if we got this far, the request was invalid
     return false;
 }
开发者ID:navtis,项目名称:xerxes,代码行数:59,代码来源:Cas.php

示例7: getCleanDomTable

 /**
  * @return DOMElement
  * @throws Exception
  */
 private function getCleanDomTable()
 {
     $dom_tables = $this->doc->getElementsByTagNameNS(static::$NS_TABLE, 'table');
     if ($dom_tables->length != 1) {
         throw new Exception("Could not parse ODS template");
     }
     $this->dom_table = $dom_tables->item(0);
     $children = $this->dom_table->childNodes;
     for ($i = $children->length - 1; $i >= 0; $i--) {
         $this->dom_table->removeChild($children->item($i));
     }
     return $this->dom_table;
 }
开发者ID:andi98,项目名称:antragsgruen,代码行数:17,代码来源:OdsTemplateEngine.php

示例8: isValid

 /**
  * Parses a validation response from a CAS server to see if the returning CAS request is valid
  *
  * @param string $strResults		xml or plain text response from cas server
  * @return bool						true if valid, false otherwise
  * @exception 						throws exception if cannot parse response or invalid version
  */
 private function isValid()
 {
     // values from the request
     $strTicket = $this->request->getProperty("ticket");
     // configuration settings
     $configCasValidate = $this->registry->getConfig("CAS_VALIDATE", true);
     // figure out which type of response this is based on the service url
     $arrURL = explode("/", $configCasValidate);
     $service = array_pop($arrURL);
     // now get it!
     $strUrl = $configCasValidate . "?ticket=" . $strTicket . "&service=" . urlencode($this->validate_url);
     $strResults = Xerxes_Framework_Parser::request($strUrl);
     // validate is plain text
     if ($service == "validate") {
         $arrMessage = explode("\n", $strResults);
         if (count($arrMessage) >= 2) {
             if ($arrMessage[0] == "yes") {
                 return $arrMessage[1];
             }
         } else {
             throw new Exception("Could not parse CAS validation response.");
         }
     } elseif ($service == "serviceValidate" || $service == "proxyValidate") {
         // these are XML based
         $objXml = new DOMDocument();
         $objXml->loadXML($strResults);
         $strCasNamespace = "http://www.yale.edu/tp/cas";
         $objUser = $objXml->getElementsByTagNameNS($strCasNamespace, "user")->item(0);
         $objFailure = $objXml->getElementsByTagNameNS($strCasNamespace, "authenticationFailure")->item(0);
         if ($objUser != null) {
             if ($objUser->nodeValue != "") {
                 return $objUser->nodeValue;
             } else {
                 throw new Exception("CAS validation response missing username value");
             }
         } elseif ($objFailure != null) {
             // see if error, rather than failed authentication
             if ($objFailure->getAttribute("code") == "INVALID_REQUEST") {
                 throw new Exception("Invalid request to CAS server: " . $objFailure->nodeValue);
             }
         } else {
             throw new Exception("Could not parse CAS validation response.");
         }
     } else {
         throw new Exception("Unsupported CAS version.");
     }
     // if we got this far, the request was invalid
     return false;
 }
开发者ID:laiello,项目名称:xerxes-portal,代码行数:56,代码来源:CAS.php

示例9: appendCellStyleNode

 /**
  * @param string $style_name
  * @param array $cellAttributes
  * @param array $textAttributes
  */
 protected function appendCellStyleNode($style_name, $cellAttributes, $textAttributes)
 {
     $node = $this->doc->createElementNS(static::$NS_STYLE, "style");
     $node->setAttribute("style:name", $style_name);
     $node->setAttribute("style:family", 'table-cell');
     $node->setAttribute("style:parent-style-name", "Default");
     if (count($cellAttributes) > 0) {
         $style = $this->doc->createElementNS(static::$NS_STYLE, 'table-cell-properties');
         foreach ($cellAttributes as $att_name => $att_val) {
             $style->setAttribute($att_name, $att_val);
         }
         $node->appendChild($style);
     }
     if (count($textAttributes) > 0) {
         $style = $this->doc->createElementNS(static::$NS_STYLE, 'text-properties');
         foreach ($textAttributes as $att_name => $att_val) {
             $style->setAttribute($att_name, $att_val);
         }
         $node->appendChild($style);
     }
     foreach ($this->doc->getElementsByTagNameNS(static::$NS_OFFICE, 'automatic-styles') as $element) {
         /** @var DOMElement $element */
         $element->appendChild($node);
     }
 }
开发者ID:andi98,项目名称:antragsgruen,代码行数:30,代码来源:OOfficeTemplateEngine.php

示例10: send

 /**
  * Send a SAML 2 message using the SOAP binding.
  *
  * Note: This function never returns.
  *
  * @param SAML2_Message $message The message we should send.
  */
 public function send(SAML2_Message $message)
 {
     $envelope = '<soap-env:Envelope xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/">' . '<soap-env:Header/><soap-env:Body /></soap-env:Envelope>';
     $doc = new DOMDocument();
     $doc->loadXML($envelope);
     $soapHeader = $doc->getElementsByTagNameNS('http://schemas.xmlsoap.org/soap/envelope/', 'Header');
     $soapBody = $doc->getElementsByTagNameNS('http://schemas.xmlsoap.org/soap/envelope/', 'Body');
     if ($message->toSignedXML()->localName === 'Response') {
         $response = new SAML2_XML_ecp_Response();
         $response->AssertionConsumerServiceURL = $this->getDestination();
         $response->toXML($soapHeader->item(0));
     }
     $soapBody->item(0)->appendChild($doc->importNode($message->toSignedXML(), true));
     print $doc->saveXML();
     exit(0);
 }
开发者ID:sitya,项目名称:saml2,代码行数:23,代码来源:SOAP.php

示例11: loadService

 /**
  * Loads the service class
  *
  * @access private
  */
 private function loadService()
 {
     $name = $this->dom->getElementsByTagNameNS('*', 'service')->item(0)->getAttribute('name');
     $this->log($this->display('Starting to load service ') . $name);
     $this->service = new Service($name, $this->types, $this->documentation->getServiceDescription());
     $functions = $this->client->__getFunctions();
     foreach ($functions as $function) {
         $matches = array();
         if (preg_match('/^(\\w[\\w\\d_]*) (\\w[\\w\\d_]*)\\(([\\w\\$\\d,_ ]*)\\)$/', $function, $matches)) {
             $returns = $matches[1];
             $function = $matches[2];
             $params = $matches[3];
         } else {
             if (preg_match('/^(list\\([\\w\\$\\d,_ ]*\\)) (\\w[\\w\\d_]*)\\(([\\w\\$\\d,_ ]*)\\)$/', $function, $matches)) {
                 $returns = $matches[1];
                 $function = $matches[2];
                 $params = $matches[3];
             } else {
                 // invalid function call
                 throw new Exception('Invalid function call: ' . $function);
             }
         }
         $this->log($this->display('Loading function ') . $function);
         $this->service->addOperation($function, $params, $this->documentation->getFunctionDescription($function));
     }
     $this->log($this->display('Done loading service ') . $name);
 }
开发者ID:rgantt,项目名称:wsdl2phpgenerator,代码行数:32,代码来源:Generator.php

示例12: extract

 /**
  * Short description of method extract
  *
  * @access public
  * @author Joel Bout, <joel.bout@tudor.lu>
  * @return mixed
  */
 public function extract()
 {
     foreach ($this->getPaths() as $path) {
         // In the RDFExtractor, we expect the paths to points directly to the file.
         if (!file_exists($path)) {
             throw new tao_helpers_translation_TranslationException("No RDF file to parse at '{$path}'.");
         } else {
             if (!is_readable($path)) {
                 throw new tao_helpers_translation_TranslationException("'{$path}' is not readable. Please check file system rights.");
             } else {
                 try {
                     $tus = array();
                     $rdfNS = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#';
                     $rdfsNS = 'http://www.w3.org/2000/01/rdf-schema#';
                     $xmlNS = 'http://www.w3.org/XML/1998/namespace';
                     // http://www.w3.org/TR/REC-xml-names/#NT-NCName
                     $translatableProperties = $this->translatableProperties;
                     // Try to parse the file as a DOMDocument.
                     $doc = new DOMDocument('1.0', 'UTF-8');
                     $doc->load(realpath($path));
                     if ($doc->documentElement->hasAttributeNS($xmlNS, 'base')) {
                         $this->xmlBase[$path] = $doc->documentElement->getAttributeNodeNS($xmlNS, 'base')->value;
                     }
                     $descriptions = $doc->getElementsByTagNameNS($rdfNS, 'Description');
                     foreach ($descriptions as $description) {
                         if ($description->hasAttributeNS($rdfNS, 'about')) {
                             $about = $description->getAttributeNodeNS($rdfNS, 'about')->value;
                             // At the moment only get rdfs:label and rdfs:comment
                             // c.f. array $translatableProperties
                             // In the future, this should be configured in the constructor
                             // or by methods.
                             $children = array();
                             foreach ($translatableProperties as $prop) {
                                 $uri = explode('#', $prop);
                                 if (count($uri) == 2) {
                                     $uri[0] .= '#';
                                     $nodeList = $description->getElementsByTagNameNS($uri[0], $uri[1]);
                                     for ($i = 0; $i < $nodeList->length; $i++) {
                                         $children[] = $nodeList->item($i);
                                     }
                                 }
                             }
                             foreach ($children as $child) {
                                 // Only process if it has a language attribute.
                                 $tus = $this->processUnit($child, $xmlNS, $about, $tus);
                             }
                         } else {
                             // Description about nothing.
                             continue;
                         }
                     }
                     $this->setTranslationUnits($tus);
                 } catch (DOMException $e) {
                     throw new tao_helpers_translation_TranslationException("Unable to parse RDF file at '{$path}'. DOM returns '" . $e->getMessage() . "'.");
                 }
             }
         }
     }
 }
开发者ID:nagyist,项目名称:tao-core,代码行数:66,代码来源:class.RDFExtractor.php

示例13: firstElementByTagNSString

 protected function firstElementByTagNSString(\DOMDocument $doc, $namespace, $tagName)
 {
     $elements = $doc->getElementsByTagNameNS($namespace, $tagName);
     if ($elements->length > 0) {
         return $elements->item(0)->nodeValue;
     }
     throw new \Exception("Tag " . $namespace . ':' . $tagName . " not found");
 }
开发者ID:checkdomain,项目名称:telecash,代码行数:8,代码来源:AbstractResponse.php

示例14: isKml

 /**
  * This returns true if the input string is KML.
  *
  * @param string $coverage The text data from the coverage field.
  *
  * @return bool $isKml Whether the string is KML.
  * @author Eric Rochester
  **/
 public static function isKml($coverage)
 {
     $isKml = false;
     $kmlNs = 'http://earth.google.com/kml/2.0';
     $names = array('Point', 'Polygon', 'LineString');
     try {
         $doc = new DOMDocument();
         @$doc->loadXML($coverage);
         $nodes = $doc->getElementsByTagNameNS($kmlNs, 'kml');
         if ($nodes->length === 1) {
             foreach ($names as $name) {
                 $isKml = $isKml || $doc->getElementsByTagNameNS($kmlNs, $name)->length > 0;
             }
         }
     } catch (Exception $e) {
     }
     return $isKml;
 }
开发者ID:rameysar,项目名称:Omeka-Grinnell-RomanCiv,代码行数:26,代码来源:NeatlineFeatures_Functions.php

示例15: XmpInformation

 function XmpInformation($stream)
 {
     $this->stream = $stream;
     $doc_root = new DOMDocument();
     $doc_root->loadXML($this->stream->get_data());
     $rdf_els = $doc_root->getElementsByTagNameNS($RDF_NAMESPACE, 'RDF');
     $this->rdf_root = $rdf_els[0];
     $this->cache = array();
 }
开发者ID:pnagaraju25,项目名称:php-pdf-parser,代码行数:9,代码来源:xmp.php


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