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


PHP DOMDocument::LoadXML方法代码示例

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


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

示例1: mapTagOnConcept

 public function mapTagOnConcept($tag, $concept, $userid, $significance, $ontologyid)
 {
     if (empty($tag) || empty($concept) || empty($significance) || empty($ontologyid)) {
         return false;
     }
     $url = $this->_mapping_endpoint . $ontologyid . '/force_mapping';
     $taglabel = $tag->getLabel();
     $uri = $concept->getUri();
     $params = "userId={$userid}&tag={$taglabel}&conceptUri={$uri}&significance={$significance}";
     //Going curl
     $ch = curl_init($url);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
     curl_setopt($ch, CURLOPT_POST, 1);
     curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
     $xmlanswer = curl_exec($ch);
     curl_close($ch);
     //Parsing the answer
     $doc = new DOMDocument();
     $doc->LoadXML($xmlanswer);
     $xpath = new DOMXPath($doc);
     //	Extracting tag information
     $query = '/tagonto';
     $requeststatus = $xpath->query($query);
     //No result here
     if ($requeststatus->length == 0) {
         return false;
     }
     //Checking requestSatisfied
     $requestresult = $requeststatus->item(0)->getAttribute('requestSatisfied');
     if ($requestresult == 'true') {
         return true;
     } else {
         return false;
     }
 }
开发者ID:paradoxengine,项目名称:tagonto,代码行数:35,代码来源:ReasoningManager.php

示例2: getResourcesForTag

 public function getResourcesForTag($tag)
 {
     //Getting the tag label
     $tagtosearch = $tag->getLabel();
     //Before everything else, we have to retrieve TAG ID from the tag name
     $tagresendpoint = 'http://www.43things.com/service/get_tags_goals?id=';
     $tagresendpoint .= $tagtosearch;
     $tagresendpoint .= '&api_key=' . $this->_APIKEY;
     $ch = curl_init($tagresendpoint);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
     $xmldoc = curl_exec($ch);
     curl_close($ch);
     //43Things will return an empty page on no match
     if (empty($xmldoc)) {
         return array();
     }
     $doc = new DOMDocument();
     $doc->preserveWhiteSpace = false;
     //Loading the XML doc
     $doc->LoadXML($xmldoc);
     $xpath = new DOMXPath($doc);
     //WE HAVE TO SETUP THINGS TO USE THE DEFAULT NAMESPACE
     $defnamespace = $doc->documentElement->lookupnamespaceURI(NULL);
     $xpath->registerNamespace('m', $defnamespace);
     //Extracting tag information
     $query = '/m:feed/m:goal';
     $entries = $xpath->query($query);
     if (empty($entries)) {
         return array();
     }
     foreach ($entries as $entry) {
         $TempRes = new Result();
         $TempRes->setUrl($entry->getElementsByTagName('link')->item(0)->getAttribute('href'));
         $TempRes->setTitle($entry->getElementsByTagName('name')->item(0)->nodeValue);
         $TempRes->setShownContent($TempRes->getUrl());
         $TempRes->setDescription('');
         $TempRes->setTagSearched($tag);
         $TempRes->setContentType(0);
         //text
         $ResourceBundle[] = $TempRes;
     }
     return $ResourceBundle;
 }
开发者ID:paradoxengine,项目名称:tagonto,代码行数:43,代码来源:manifest.php

示例3: StaticDomDocumentReplace

 protected static function StaticDomDocumentReplace(&$String)
 {
     if (substr(ltrim($String), 0, 5) != '<?xml') {
         $String = '<?xml version="1.0" encoding="UTF-8"?' . ">\n" . $String;
     }
     $DOMDocument = DOMDocument::LoadXML($String, LIBXML_NOERROR);
     if ($DOMDocument === False) {
         return $String;
     }
     $ImageDimensions = self::ImageDimensions();
     $BeforeCount = count($ImageDimensions);
     $Domain = Gdn::Request()->Domain();
     $DomNodeList = $DOMDocument->GetElementsByTagName('img');
     for ($i = $DomNodeList->length - 1; $i >= 0; $i--) {
         $Node = $DomNodeList->Item($i);
         $Width = $Node->GetAttribute('width');
         $Height = $Node->GetAttribute('height');
         if ($Width == '' && $Height == '') {
             $Src = $Node->GetAttribute('src');
             if (!$Src) {
                 continue;
             }
             $Src = AbsoluteSource($Src, $Domain);
             $CrcKey = crc32($Src);
             if (!array_key_exists($CrcKey, $ImageDimensions)) {
                 $ImageSize = getimagesize($Src);
                 $ImageDimensions[$CrcKey] = array($ImageSize[0], $ImageSize[1], '_src' => $Src);
             } else {
                 $ImageSize = $ImageDimensions[$CrcKey];
             }
             if ($ImageSize[0] && $ImageSize[1]) {
                 $Node->SetAttribute('width', $ImageSize[0]);
                 $Node->SetAttribute('height', $ImageSize[1]);
             }
         }
     }
     // Save cache.
     if (count($ImageDimensions) != $BeforeCount) {
         self::ImageDimensions($ImageDimensions);
     }
     $String = $DOMDocument->saveXML();
     // LIBXML_NOXMLDECL | LIBXML_NOENT
     //$DOMDocument->formatOutput = True;
     //$String = $DOMDocument->saveXML(Null, LIBXML_NOXMLDECL | LIBXML_NOENT);
     //d($String);
 }
开发者ID:ru4,项目名称:arabbnota,代码行数:46,代码来源:class.pagespeed.plugin.php

示例4: DownloadMarkup

 function DownloadMarkup()
 {
     $resourceService = $this->site->CreateService(MgServiceType::ResourceService);
     $featureService = $this->site->CreateService(MgServiceType::FeatureService);
     $markupLayerResId = new MgResourceIdentifier($this->args['MARKUPLAYER']);
     $markupFsId = new MgResourceIdentifier($this->GetResourceIdPrefix() . $markupLayerResId->GetName() . '.FeatureSource');
     $extension = $this->GetFileExtension($markupLayerResId->ToString());
     if (strcmp($extension, ".zip") == 0) {
         $dataList = $resourceService->EnumerateResourceData($markupFsId);
         $doc = DOMDocument::LoadXML($dataList->ToString());
         $dataItems = $doc->getElementsByTagName("Name");
         $tmpFiles = array();
         //Copy out all data files to a temp location
         for ($i = 0; $i < $dataItems->length; $i++) {
             $dataName = $dataItems->item($i)->nodeValue;
             $byteReader = $resourceService->GetResourceData($markupFsId, $dataName);
             //Sink to temp file
             $tmpSink = new MgByteSink($byteReader);
             $fileName = tempnam(sys_get_temp_dir(), $dataName);
             $tmpSink->ToFile($fileName);
             $tmpFiles[$dataName] = $fileName;
         }
         //Zip them up.
         $zipName = $markupLayerResId->GetName() . $extension;
         $zipPath = tempnam(sys_get_temp_dir(), $zipName);
         $zip = new ZipArchive();
         $zip->open($zipPath, ZIPARCHIVE::CREATE);
         foreach ($tmpFiles as $dataName => $filePath) {
             $dataNorm = strtolower($dataName);
             //HACK: There must be some defect in MgFeatureService::CreateFeatureSource() for SHP
             //files or the FDO provider, because even if we plug in a coord sys WKT when we create
             //it, we get a blank prj file (both Windows/Linux). Re-uploading this same zip file back into
             //the widget causes problems in Linux (markup features not rendered) because of the blank prj.
             //
             //So that's the problem. Here's the workaround: If we find a blank prj file as we're assembling
             //the zip file for download, pump our current Map's WKT into the prj file before packaging it up
             //
             //That's what we were already doing when we called MgFeatureService::CreateFeatureSource(), but it
             //or the provider didn't like it.
             if (substr($dataNorm, strlen($dataNorm) - strlen("prj")) == "prj") {
                 $content = file_get_contents($filePath);
                 if (strlen($content) == 0) {
                     $map = new MgMap();
                     $map->Open($resourceService, $this->args['MAPNAME']);
                     $content = $map->GetMapSRS();
                     file_put_contents($filePath, $content);
                 }
             }
             $zip->addFile($filePath, $dataName);
         }
         $zip->close();
         //Serve it up for download
         $bs = new MgByteSource($zipPath);
         $br = $bs->GetReader();
         $len = $br->GetLength();
         $outputBuffer = '';
         $buffer = '';
         while ($br->Read($buffer, 50000) != 0) {
             $outputBuffer .= $buffer;
         }
         header("Content-Type: application/octet-stream");
         header("Content-Disposition: attachment; filename={$zipName}");
         header("Content-Length: " . strlen($outputBuffer));
         echo $outputBuffer;
         //Let's be nice and clean up after ourselves
         unlink($zipPath);
         foreach ($tmpFiles as $dataName => $filePath) {
             unlink($filePath);
         }
     } else {
         //Single file, make things easier!
         $dataName = $markupLayerResId->GetName() . $extension;
         $byteReader = $resourceService->GetResourceData($markupFsId, $dataName);
         $len = $byteReader->GetLength();
         $outputBuffer = '';
         $buffer = '';
         while ($byteReader->Read($buffer, 50000) != 0) {
             $outputBuffer .= $buffer;
         }
         header("Content-Type: " . $byteReader->GetMimeType());
         header("Content-Disposition: attachment; filename={$dataName}");
         header("Content-Length: " . strlen($outputBuffer));
         echo $outputBuffer;
     }
 }
开发者ID:kanbang,项目名称:Colt,代码行数:85,代码来源:markupmanager.php

示例5: array

     $layer = $layers->GetItem($i);
     $lid = $layer->GetLayerDefinition();
     $layerDefinitionIds->Add($lid->ToString());
     $featureSourceIds->Add($layer->GetFeatureSourceId());
 }
 //Get the layer contents in a single batch
 $layerDefinitionContents = $resourceService->GetResourceContents($layerDefinitionIds, null);
 $featureSourceContents = $resourceService->GetResourceContents($featureSourceIds, null);
 $layerDocs = array();
 $fsDocs = array();
 for ($i = 0; $i < $layers->GetCount(); $i++) {
     $ldfContent = $layerDefinitionContents->GetItem($i);
     $ldfdoc = DOMDocument::LoadXML($ldfContent);
     array_push($layerDocs, $ldfdoc);
     $fsContent = $featureSourceContents->GetItem($i);
     $fsDoc = DOMDocument::LoadXML($fsContent);
     array_push($fsDocs, $fsDoc);
 }
 for ($i = 0; $i < $layers->GetCount(); $i++) {
     //only output layers that are part of the 'Normal Group' and
     //not the base map group used for tile maps.  (Where is the test for that Y.A.???)
     $layer = $layers->GetItem($i);
     $layerContent = $layerDocs[$i];
     $fsContent = $fsDocs[$i];
     $layerObj = NULL;
     $mappings = GetLayerPropertyMappings($resourceService, $layer, $layerContent);
     $_SESSION['property_mappings'][$layer->GetObjectId()] = $mappings;
     $layerObj->uniqueId = $layer->GetObjectId();
     $layerObj->layerName = addslashes($layer->GetName());
     //$aLayerTypes = GetLayerTypes($featureService, $layer);
     $aLayerTypes = GetLayerTypesFromResourceContent($layer, $layerContent);
开发者ID:kanbang,项目名称:Colt,代码行数:31,代码来源:LoadMap.php

示例6: getRelatedTags

 public function getRelatedTags($tag)
 {
     $taglabel = $tag->getLabel();
     //Retrieving related tags
     //Getting the tag label
     $tagtosearch = $tag->getLabel();
     //To retrieve tag friends, we have to search for a tag and then
     //retrieve all the tags listed in the same document
     $tagendpoint = 'http://www.connotea.org/data/bookmarks/tag/';
     $tagendpoint .= $tagtosearch;
     $ch = curl_init($tagendpoint);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
     curl_setopt($ch, CURLOPT_HEADER, 0);
     curl_setopt($ch, CURLOPT_USERPWD, $this->_username . ":" . $this->_password);
     curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
     $xmldoc = curl_exec($ch);
     curl_close($ch);
     if (empty($xmldoc)) {
         return array();
     }
     $doc = new DOMDocument();
     $doc->preserveWhiteSpace = false;
     //Loading the XML doc
     $doc->LoadXML($xmldoc);
     $xpath = new DOMXPath($doc);
     //registering the namespaces, both the dcterms one and the default one
     $defnamespace = $doc->documentElement->lookupnamespaceURI("dcterms");
     $xpath->registerNamespace('dcterms', $defnamespace);
     $xpath->registerNamespace('def', "http://www.connotea.org/2005/01/schema#");
     //$defnamespace2 = $doc->documentElement->lookupnamespaceURI("dcterms");
     //Extracting result information
     $query = '//dcterms:URI/def:tag';
     $entries = $xpath->query($query);
     //No tag found
     if ($entries->length == 0) {
         return array();
     }
     $TempStorage = array();
     foreach ($entries as $eletagtag) {
         if (!in_array($eletagtag->nodeValue, $TempStorage)) {
             $TempStorage[] = $eletagtag->nodeValue;
         }
     }
     foreach ($TempStorage as $taglabel) {
         $ResourceBundle[] = new Tag($taglabel);
     }
     //TODO number of matches?
     //Building return array
     return $ResourceBundle;
 }
开发者ID:paradoxengine,项目名称:tagonto,代码行数:50,代码来源:manifest.php


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