本文整理汇总了PHP中DOMDocument::load方法的典型用法代码示例。如果您正苦于以下问题:PHP DOMDocument::load方法的具体用法?PHP DOMDocument::load怎么用?PHP DOMDocument::load使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DOMDocument
的用法示例。
在下文中一共展示了DOMDocument::load方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* @param string $sourceFile
* @throws Exception
*/
public function __construct($sourceFile)
{
$this->sourceFile = $sourceFile;
$this->originalDir = dirname($sourceFile) . "/original";
$this->convertedDir = dirname($sourceFile) . "/converted";
$this->extractXPI($sourceFile, $this->originalDir, true);
$this->extractXPI($sourceFile, $this->convertedDir, false);
if (!is_file($this->convertedDir . "/install.rdf")) {
throw new Exception("install.rdf not found in installer");
}
$this->installRdf = new DOMDocument('1.0', 'utf-8');
$this->installRdf->preserveWhiteSpace = false;
$this->installRdf->formatOutput = true;
$result = @$this->installRdf->load($this->convertedDir . "/install.rdf");
$this->installRdf->encoding = 'utf-8';
if (!$result) {
throw new Exception("Cannot parse install.rdf as XML");
}
$this->addonName = $this->getAddonNameFromInstallRdf($this->installRdf);
$this->chromeURLReplacements = array('chrome://browser/content/browser.xul' => 'chrome://navigator/content/navigator.xul', 'chrome://browser/content/pageinfo/pageInfo.xul' => 'chrome://navigator/content/pageinfo/pageInfo.xul', 'chrome://browser/content/preferences/permissions.xul' => 'chrome://communicator/content/permissions/permissionsManager.xul', 'chrome://browser/content/bookmarks/bookmarksPanel.xul' => 'chrome://communicator/content/bookmarks/bm-panel.xul', 'chrome://browser/content/places/places.xul' => 'chrome://communicator/content/bookmarks/bookmarksManager.xul', 'chrome://browser/content/preferences/sanitize.xul' => 'chrome://communicator/content/sanitize.xul', 'chrome://browser/content/nsContextMenu.js' => 'chrome://communicator/content/nsContextMenu.js', 'chrome://browser/content/utilityOverlay.js' => 'chrome://communicator/content/utilityOverlay.js', 'chrome://browser/content/history/history-panel.xul' => 'chrome://communicator/content/history/history-panel.xul', 'chrome://browser/content/places/menu.xml' => 'chrome://communicator/content/places/menu.xml', 'chrome://browser/content/search/engineManager.js' => 'chrome://communicator/content/search/engineManager.js', 'chrome://browser/locale/places/editBookmarkOverlay.dtd' => 'chrome://communicator/locale/bookmarks/editBookmarkOverlay.dtd', 'chrome://browser/locale/places/places.dtd' => 'chrome://communicator/locale/bookmarks/places.dtd', 'chrome://browser/content/places/bookmarkProperties.xul' => 'chrome://communicator/content/bookmarks/bm-props.xul', 'chrome://browser/content/places/bookmarkProperties2.xul' => 'chrome://communicator/content/bookmarks/bm-props.xul', 'chrome://browser/skin/livemark-folder.png' => 'chrome://communicator/skin/bookmarks/livemark-folder.png', 'chrome://browser/content/' => 'chrome://navigator/content/', 'resource:///modules/sessionstore/SessionStore.jsm' => 'resource:///components/nsSessionStore.js');
foreach (scandir(self::MISSING_FILES_DIR) as $filename) {
$file = self::MISSING_FILES_DIR . "/{$filename}";
if ($filename[0] != '.' && is_file($file)) {
$this->missingChromeURLs[$filename] = 'chrome://' . str_replace('+', '/', $filename);
}
}
}
示例2: loadFile
/**
* Load XML file
*
* @param string $filepath
* @return void
*/
protected function loadFile($filepath)
{
$this->xmlDoc = new \DOMDocument('1.0', 'utf-8');
$this->xmlDoc->load($filepath);
// @TODO: oliver@typo3.org: I guess this is not required here
$this->xmlDoc->saveXML();
}
示例3: __construct
/**
* @param $templateName
* @param $distributionProfile
*/
public function __construct($templateName)
{
$xmlTemplate = realpath(dirname(__FILE__) . '/../') . '/xml/' . $templateName;
$this->doc = new KDOMDocument();
$this->doc->formatOutput = true;
$this->doc->preserveWhiteSpace = false;
$this->doc->load($xmlTemplate);
$this->xpath = new DOMXPath($this->doc);
$this->xpath->registerNamespace('media', 'http://search.yahoo.com/mrss/');
$this->xpath->registerNamespace('dcterms', 'http://purl.org/dc/terms/');
$this->xpath->registerNamespace('cim', 'http://labs.comcast.net/cim_mrss/');
// item node template
$node = $this->xpath->query('/rss/channel/item')->item(0);
$this->item = $node->cloneNode(true);
$node->parentNode->removeChild($node);
// content node template
$node = $this->xpath->query('media:group/media:content', $this->item)->item(0);
$this->content = $node->cloneNode(true);
$node->parentNode->removeChild($node);
// thumbnail node template
$node = $this->xpath->query('media:group/media:thumbnail', $this->item)->item(0);
$this->thumbnail = $node->cloneNode(true);
$node->parentNode->removeChild($node);
// category node template
$node = $this->xpath->query('media:group/media:category', $this->item)->item(0);
$this->category = $node->cloneNode(true);
$node->parentNode->removeChild($node);
}
示例4: initRepository
private function initRepository()
{
$this->repository = new \DOMDocument('1.0', 'UTF-8');
$this->repository->load(__DIR__ . '/../templates/phive.xml');
$this->xp = new \DOMXPath($this->repository);
$this->xp->registerNamespace('phive', 'https://phar.io/repository');
}
示例5: __construct
/**
* @param $templateName
* @param $distributionProfile
*/
public function __construct($templateName)
{
$xmlTemplate = realpath(dirname(__FILE__) . '/../') . '/xml/' . $templateName;
$this->doc = new KDOMDocument();
$this->doc->formatOutput = true;
$this->doc->preserveWhiteSpace = false;
$this->doc->load($xmlTemplate);
$this->xpath = new DOMXPath($this->doc);
$this->xpath->registerNamespace('media', 'http://search.yahoo.com/mrss/');
$this->xpath->registerNamespace('dcterms', 'http://purl.org/dc/terms/');
$this->xpath->registerNamespace('pl', 'http://xml.theplatform.com/data/object');
$this->xpath->registerNamespace('pllist', 'http://xml.theplatform.com/data/list');
$this->xpath->registerNamespace('plfile', 'http://xml.theplatform.com/media/data/MediaFile');
$this->xpath->registerNamespace('plmedia', 'http://xml.theplatform.com/media/data/Media');
$this->xpath->registerNamespace('pla', 'http://xml.theplatform.com/data/object/admin');
$this->xpath->registerNamespace('twcable', 'http://twcable.com/customfields');
// item node template
$node = $this->xpath->query('/rss/channel/item')->item(0);
$this->item = $node->cloneNode(true);
$node->parentNode->removeChild($node);
// content node template
$node = $this->xpath->query('media:group/media:content', $this->item)->item(0);
$this->content = $node->cloneNode(true);
$node->parentNode->removeChild($node);
// category node template
$node = $this->xpath->query('media:category', $this->item)->item(0);
$this->category = $node->cloneNode(true);
$node->parentNode->removeChild($node);
}
示例6: __construct
/**
* @param $templateName
* @param DoubleClickDistributionProfile $profile
* @param $distributionProfile
*/
public function __construct($templateName, DoubleClickDistributionProfile $profile)
{
$xmlTemplate = realpath(dirname(__FILE__) . '/../') . '/xml/' . $templateName;
$this->distributionProfile = $profile;
$this->doc = new KDOMDocument('1.0', 'UTF-8');
$this->doc->formatOutput = true;
$this->doc->preserveWhiteSpace = false;
$this->doc->load($xmlTemplate);
$this->xpath = new DOMXPath($this->doc);
$this->xpath->registerNamespace('media', 'http://search.yahoo.com/mrss/');
$this->xpath->registerNamespace('atom', 'http://www.w3.org/2005/Atom');
$this->xpath->registerNamespace('openSearch', 'http://a9.com/-/spec/opensearchrss/1.0/');
$this->xpath->registerNamespace('dfpvideo', 'http://api.google.com/dfpvideo');
// item node template
$node = $this->xpath->query('/rss/channel/item')->item(0);
$this->item = $node->cloneNode(true);
$node->parentNode->removeChild($node);
// content node template
$node = $this->xpath->query('media:group/media:content', $this->item)->item(0);
$this->content = $node->cloneNode(true);
$node->parentNode->removeChild($node);
// thumbnail node template
$node = $this->xpath->query('media:group/media:thumbnail', $this->item)->item(0);
$this->thumbnail = $node->cloneNode(true);
$node->parentNode->removeChild($node);
// category node template
$node = $this->xpath->query('media:group/media:category', $this->item)->item(0);
$this->category = $node->cloneNode(true);
$node->parentNode->removeChild($node);
// set profile properties
$this->setNodeValue('/rss/channel/title', $profile->getChannelTitle());
$this->setNodeValue('/rss/channel/description', $profile->getChannelDescription());
$this->setNodeValue('/rss/channel/link', $profile->getChannelLink());
$this->setItemsPerPage($profile->getItemsPerPage());
}
示例7: getProductsReview
/**
* get product reviews from feefo
*
* @return array
*/
public function getProductsReview()
{
$check = true;
$reviews = array();
$feefo_dir = Mage::getModel('core/config_options')->getLibDir() . DS . 'connector' . DS . 'feefo';
$helper = Mage::helper('ddg');
$logon = $helper->getFeefoLogon();
$limit = $helper->getFeefoReviewsPerProduct();
$products = $this->getQuoteProducts();
foreach ($products as $sku => $name) {
$url = "http://www.feefo.com/feefo/xmlfeed.jsp?logon=" . $logon . "&limit=" . $limit . "&vendorref=" . $sku . "&mode=productonly";
$doc = new DOMDocument();
$xsl = new XSLTProcessor();
if ($check) {
$doc->load($feefo_dir . DS . "feedback.xsl");
} else {
$doc->load($feefo_dir . DS . "feedback-no-th.xsl");
}
$xsl->importStyleSheet($doc);
$doc->load($url);
$productReview = $xsl->transformToXML($doc);
if (strpos($productReview, '<td')) {
$reviews[$name] = $xsl->transformToXML($doc);
}
$check = false;
}
return $reviews;
}
示例8: __construct
/**
* @param $templateName
* @param $distributionProfile
*/
public function __construct($templateName)
{
$xmlTemplate = realpath(dirname(__FILE__) . '/../') . '/xml_templates/' . $templateName;
$this->doc = new KDOMDocument();
$this->doc->load($xmlTemplate);
$this->xpath = new DOMXPath($this->doc);
}
开发者ID:EfncoPlugins,项目名称:Media-Management-based-on-Kaltura,代码行数:11,代码来源:IdeticDistributionFeedHelper.php
示例9: isset
function __construct($xmlPath, Zend_Config $config, $sourcePath = "sources/java")
{
parent::__construct($xmlPath, $sourcePath, $config);
$this->_usePrivateAttributes = isset($config->usePrivateAttributes) ? $config->usePrivateAttributes : false;
$this->_doc = new KDOMDocument();
$this->_doc->load($this->_xmlFile);
}
示例10: __construct
/**
* @param Set $set
* @param string $path
*/
public function __construct(Set $set, $path)
{
$this->set = $set;
$this->path = $path;
$this->dom = new \DOMDocument();
$this->dom->load($path);
$xpath = new \DOMXPath($this->dom);
$xpath->registerNamespace('link', 'http://www.xbrl.org/2003/linkbase');
$xpath->registerNamespace('linkbase', 'http://www.xbrl.org/2003/linkbase');
$lls = array();
/** @var $element \DOMElement */
foreach ($xpath->evaluate('//link:linkbase/*') as $element) {
switch ($element->nodeName) {
case 'labelLink':
$lls[] = new Label\Link($this, $element);
break;
case 'referenceLink':
$lls[] = new Reference\Link($this, $element);
break;
case 'presentationLink':
$lls[] = new Presentation\Link($this, $element);
break;
case 'calculationLink':
$lls[] = new Calculation\Link($this, $element);
break;
case 'definitionLink':
$lls[] = new Definition\Link($this, $element);
break;
}
}
$this->links = $lls;
}
示例11: getProductsReview
/**
* get product reviews from feefo
*
* @return array
*/
public function getProductsReview()
{
$check = true;
$reviews = array();
$feefoDir = BP . DIRECTORY_SEPARATOR . 'app' . DIRECTORY_SEPARATOR . 'code' . DIRECTORY_SEPARATOR . 'Dotdigitalgroup' . DIRECTORY_SEPARATOR . 'Email' . DIRECTORY_SEPARATOR . 'view' . DIRECTORY_SEPARATOR . 'frontend' . DIRECTORY_SEPARATOR . 'templates' . DIRECTORY_SEPARATOR . 'feefo';
$logon = $this->helper->getFeefoLogon();
$limit = $this->helper->getFeefoReviewsPerProduct();
$products = $this->getQuoteProducts();
foreach ($products as $sku => $name) {
$url = "http://www.feefo.com/feefo/xmlfeed.jsp?logon=" . $logon . "&limit=" . $limit . "&vendorref=" . $sku . "&mode=productonly";
$doc = new \DOMDocument();
$xsl = new \XSLTProcessor();
if ($check) {
$doc->load($feefoDir . DIRECTORY_SEPARATOR . "feedback.xsl");
} else {
$doc->load($feefoDir . DIRECTORY_SEPARATOR . "feedback-no-th.xsl");
}
$xsl->importStyleSheet($doc);
$doc->loadXML(file_get_contents($url));
$productReview = $xsl->transformToXML($doc);
if (strpos($productReview, '<td') !== false) {
$reviews[$name] = $xsl->transformToXML($doc);
}
$check = false;
}
return $reviews;
}
示例12: preExecute
/**
* Pre-execute action - before every action
*
* @author Sergey Startsev
*/
public function preExecute()
{
$module_name = $this->getModuleName();
$action_name = $this->getActionName();
// init widget uri
$this->widgetUri = "{$module_name}/{$action_name}";
// getting xml file path
$xmlCU = new afConfigUtils($module_name);
$xml_path = $xmlCU->getConfigFilePath($action_name . '.xml', true);
// initialize dom document
$this->dom_xml = new DOMDocument();
$this->dom_xml->preserveWhiteSpace = false;
$this->dom_xml->formatOutput = true;
$this->dom_xml->load($xml_path);
$this->dom_xml_xpath = new DOMXPath($this->dom_xml);
// getting datasource class
$peerClassName = $this->getDatasource();
if (!empty($peerClassName) && class_exists($peerClassName)) {
$modelClassName = constant("{$peerClassName}::OM_CLASS");
$formClassName = "{$modelClassName}Form";
$this->tryToLoadObjectFromRequest($peerClassName);
if (!$this->object) {
$this->createNewObject($modelClassName);
}
$this->createAndConfigureForm($formClassName);
}
}
示例13: __construct
/**
* @param $templateName
* @param $distributionProfile
*/
public function __construct($templateName)
{
$xmlTemplate = realpath(dirname(__FILE__) . '/../') . '/xml/' . $templateName;
$this->doc = new KDOMDocument();
$this->doc->formatOutput = true;
$this->doc->preserveWhiteSpace = false;
$this->doc->load($xmlTemplate);
//namespaces
$this->xpath = new DOMXPath($this->doc);
$this->xpath->registerNamespace('live', 'http://live.com/schema/media/');
$this->xpath->registerNamespace('media', 'http://search.yahoo.com/mrss/');
$this->xpath->registerNamespace('abcnews', 'http://abcnews.com/content/');
// item node template
$node = $this->xpath->query('/rss/channel/item')->item(0);
$this->item = $node->cloneNode(true);
$node->parentNode->removeChild($node);
// thumbnail node template
$node = $this->xpath->query('media:thumbnail', $this->item)->item(0);
$this->thumbnail = $node->cloneNode(true);
$node->parentNode->removeChild($node);
// category node template
$node = $this->xpath->query('media:category', $this->item)->item(0);
$this->category = $node->cloneNode(true);
$node->parentNode->removeChild($node);
}
示例14: KDOMDocument
function __construct($xmlPath, Zend_Config $config, $sourcePath = "sources/bpmn")
{
parent::__construct($xmlPath, $sourcePath, $config);
$this->template = file_get_contents("{$sourcePath}/action.template.bpmn");
$this->excludeSourcePaths[] = 'action.template.bpmn';
$this->_doc = new KDOMDocument();
$this->_doc->load($this->_xmlFile);
}
示例15: getValuesFromXML
function getValuesFromXML()
{
$xml_location = $this->get('xml_location');
$cache_life = (int) $this->get('cache');
require TOOLKIT . '/util.validators.php';
// allow use of choice params in URL
$xml_location = preg_replace('/{\\$root}/', URL, $xml_location);
$xml_location = preg_replace('/{\\$workspace}/', WORKSPACE, $xml_location);
$doc = new DOMDocument();
if (preg_match($validators['URI'], $xml_location)) {
// is a URL, check cache
$cache_id = md5('xml_selectbox_' . $xml_location);
$cache = new Cacheable($this->_Parent->_Parent->Database);
$cachedData = $cache->check($cache_id);
if (!$cachedData) {
$ch = new Gateway();
$ch->init();
$ch->setopt('URL', $xml_location);
$ch->setopt('TIMEOUT', 6);
$xml = $ch->exec();
$writeToCache = true;
$cache->write($cache_id, $xml, $cache_life);
// Cache life is in minutes not seconds e.g. 2 = 2 minutes
$xml = trim($xml);
if (empty($xml) && $cachedData) {
$xml = $cachedData['data'];
}
} else {
$xml = $cachedData['data'];
}
$doc->loadXML($xml);
} elseif (substr($xml_location, 0, 1) == '/') {
// relative to DOCROOT
$doc->load(DOCROOT . $this->get('xml_location'));
} else {
// in extension's /xml folder
$doc->load(EXTENSIONS . '/xml_selectbox/xml/' . $this->get('xml_location'));
}
$xpath = new DOMXPath($doc);
$options = array();
foreach ($xpath->query($this->get('item_xpath')) as $item) {
$option = array();
$option['text'] = $this->run($xpath, $item, $this->get('text_xpath'));
$option['value'] = $this->run($xpath, $item, $this->get('value_xpath'));
if (is_null($option['value'])) {
$option['value'] = $option['text'];
}
$options[] = $option;
if ($item->hasChildNodes()) {
foreach ($xpath->query('*', $item) as $child) {
$text = $this->run($xpath, $child, $this->get('text_xpath'));
$value = $this->run($xpath, $child, $this->get('value_xpath'));
$options[] = array('text' => $option['text'] . " / " . $text, 'value' => $option['value'] . "-" . (!is_null($value) ? $value : $text));
}
}
}
return $options;
}