本文整理汇总了PHP中DomDocument::load方法的典型用法代码示例。如果您正苦于以下问题:PHP DomDocument::load方法的具体用法?PHP DomDocument::load怎么用?PHP DomDocument::load使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DomDocument
的用法示例。
在下文中一共展示了DomDocument::load方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: buildDomDocument
public function buildDomDocument($xsltFileName)
{
$xslt = new DomDocument();
if (file_exists($xsltFileName . '_custom.xslt')) {
$xslt->load($xsltFileName . '_custom.xslt');
} else {
$xslt->load($xsltFileName . '.xslt');
}
return $xslt;
}
示例2: get_document
function get_document($aNode)
{
//get the directory in which the documents are contained from the config.php file
global $xml_dir, $html_dir, $xslt, $html_xslt;
//create the xslt
$xp = new XsltProcessor();
// create a DOM document and load the XSL stylesheet
$xsl = new DomDocument();
$xsl->load($xslt);
// import the XSL styelsheet into the XSLT process
$xp->importStylesheet($xsl);
//open the xml document
$xml = new DomDocument();
$xml->loadXML($aNode);
//transform
if ($html = $xp->transformToXML($xml)) {
$return = str_replace('<?xml version="1.0"?>' . "\n", "", $html);
$return = str_replace('<!DOCTYPE div PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">' . "\n", "", $return);
$return = str_replace("\n", "", $return);
$return = str_replace("\n ", "", $return);
return str_replace("\t", "", $return);
} else {
trigger_error('XSL transformation failed.', E_USER_ERROR);
}
}
示例3: pullStats
function pullStats($set)
{
$xp = new XsltProcessor();
// create a DOM document and load the XSL stylesheet
$xsl = new DomDocument();
$xsl->load('stats.xslt');
// import the XSL styelsheet into the XSLT process
$xp->importStylesheet($xsl);
// create a DOM document and load the XML datat
$xml_doc = new DomDocument();
$xml_doc->load('xmlcache/' . $set . '.xml');
// transform the XML into HTML using the XSL file
if ($xml = $xp->transformToXML($xml_doc)) {
$stats_xml = simplexml_load_string($xml);
$temp_bottom = array();
$temp_top = array();
foreach ($stats_xml->top as $top) {
array_push($temp_top, (string) $top);
}
foreach ($stats_xml->bottom as $bottom) {
array_push($temp_bottom, (string) $bottom);
}
$temp_return = array('bottom' => $temp_bottom, 'top' => $temp_top, 'total' => (string) $stats_xml->total);
return $temp_return;
}
}
示例4: render
public function render()
{
eval("\$this->content = \$this->parse{$this->requesttype}();");
$this->checkFor404();
if ($this->format === 'object') {
$this->printObject($this);
} else {
ob_start();
$file = $this->root . '/lib/xml/pigment.xml';
echo '<?xml version="1.0" encoding="ISO-8859-1"?>' . "\n";
if (is_file($file)) {
include $file;
}
$xml = ob_get_contents();
ob_end_clean();
}
if ($this->format === 'xml') {
$type = $this->getHeader('xml');
header("Content-Type: {$type}");
echo $xml;
} else {
if ($this->format === 'default') {
if ($this->requesttype === 'Content') {
$type = $this->getHeader('xml');
$file = "{$this->root}/lib/xsl/{$this->version}.xsl";
if (!is_file($file)) {
$file = "{$this->root}/lib/xsl/default.xsl";
}
$xmldoc = DOMDocument::loadXML($xml);
$xsldoc = new DomDocument();
$xsldoc->load($file);
$proc = new XSLTProcessor();
$proc->registerPHPFunctions();
$proc->importStyleSheet($xsldoc);
$output = $proc->transformToXML($xmldoc);
$selector = '</html>';
if (strstr($output, $selector)) {
$exp = explode($selector, $output);
$uri = $_SERVER['REQUEST_URI'];
$delim = strstr($uri, '?') ? '&' : '?';
$track = '<object type="text/html" width="1" height="1" data="' . $uri . $delim . 'log"></object>';
$output = implode($track . '</html>', $exp);
}
} else {
$output = $this->content;
}
}
}
if (isset($output)) {
if (isset($this->is404) && $this->is404 === true) {
header(' ', true, 404);
} else {
header("Content-Type: {$this->header}");
}
echo $output;
if ($this->preferences['cache'] && !isset($this->querystring) && !isset($this->is404)) {
$this->cache($output);
}
}
}
示例5: get_xml_droits
function get_xml_droits()
{
if (!is_file(PATH_ROOT . 'inc/droits.xml')) {
return array();
}
$dom = new DomDocument("1.0", "UTF-8");
$dom->load(PATH_ROOT . 'inc/droits.xml');
$elements = $dom->getElementsByTagName('droits');
$arbre = $elements->item(0);
$array_droit = array();
$sections = $arbre->childNodes;
foreach ($sections as $section) {
if ($section->nodeName == "section") {
$nom_section = $section->attributes->getNamedItem("name")->nodeValue;
$array_droit[$nom_section] = array();
$droits = $section->childNodes;
foreach ($droits as $droit) {
if ($droit->nodeName == "droit") {
$infos_droit = $droit->childNodes;
$nom_droit = $droit->getElementsByTagName("name")->item(0)->nodeValue;
$type_droit = $droit->getElementsByTagName("type")->item(0)->nodeValue;
$array_droit[$nom_section][$nom_droit] = array($type_droit);
}
}
}
}
return $array_droit;
}
示例6: table
protected function table($doName)
{
$doName = substr($doName, 1);
$doName = $this->getFormObj()->getElement($doName)->m_Value;
// get the dataobj file
$metaFileInfo = $this->getFormObj()->GetMetaFileInfo();
if (!$metaFileInfo) {
return "";
}
//echo "meta file info:"; print_r($metaFileInfo);
if ($doName && !strpos($doName, ".") && $metaFileInfo['package']) {
// no package prefix as package.object, add it
$doName = $metaFileInfo['package'] . "." . $doName;
}
$doFile = $metaFileInfo['modules_path'] . str_replace(".", "/", $doName) . '.xml';
// get the fields of the dataobj
$xpathStr = "/BizDataObj/@Table";
if (!file_exists($doFile)) {
return "";
}
$doc = new DomDocument();
$ok = $doc->load($doFile);
if (!$ok) {
return "";
}
$xpath = new DOMXPath($doc);
$elems = $xpath->query($xpathStr);
$tableAttr = $elems->item(0);
$table = $tableAttr->value;
return $table;
}
示例7: TeiDisplay
public function TeiDisplay($file, array $options = array())
{
if ($file->getExtension() != "xml") {
return "";
}
//queue_css_file('tei_display_public', 'screen', false, "plugins/TeiDisplay/views/public/css");
//echo "<h3>displaying ", $file->original_filename, "</h3><br/>";
$files = $file->getItem()->Files;
foreach ($files as $f) {
if ($f->getExtension() == "xsl") {
$xsl_file = $f;
}
if ($f->getExtension() == "css") {
$css_file = $f;
}
}
//queue_css_url($css_file->getWebPath());
echo '<link rel="stylesheet" media="screen" href="' . $css_file->getWebPath() . '"/>';
//echo "transforming with ", $xsl_file->original_filename, "<br/>";
$xp = new XsltProcessor();
$xsl = new DomDocument();
//echo "loading ", "files/original/".$xsl_file->filename, "<br/>";
$xsl->load("files/original/" . $xsl_file->filename);
$xp->importStylesheet($xsl);
$xml_doc = new DomDocument();
//echo "loading ", "files/original/".$file->filename, "<br/>";
$xml_doc->load("files/original/" . $file->filename);
try {
if ($doc = $xp->transformToXML($xml_doc)) {
return $doc;
}
} catch (Exception $e) {
$this->view->error = $e->getMessage();
}
}
示例8: load
/**
* Read from file
*/
function load(&$ctx)
{
$dom = new DomDocument();
$dom->load($this->path);
$dom->xinclude();
$this->xml = simplexml_import_dom($dom);
}
示例9: civicrm_diagnostic
function civicrm_diagnostic()
{
require_once '../civicrm.config.php';
require_once 'CRM/Core/Config.php';
$config =& new CRM_Core_Config();
$drupalPath = explode('/', $config->templateCompileDir);
$pathArray = array();
foreach ($drupalPath as $path) {
if ($path == 'files') {
break;
}
$pathArray[] = $path;
}
$drupalPath = implode('/', $pathArray);
$PHPVersion = phpversion();
$mysqlPath = $config->mysqlPath;
$mysqlVersion = exec($mysqlPath . 'mysql --version');
$versionFile = "../xml/version.xml";
$dom = DomDocument::load($versionFile);
$dom->xinclude();
$versionXML = simplexml_import_dom($dom);
$civicrmVersion = $versionXML->version_no;
$f = fopen($drupalPath . '/CHANGELOG.txt', 'r');
list(, $version) = explode(' ', fgets($f, 13));
fclose($f);
$drupalVersion = $version;
//echo "PHP Version : ".$PHPVersion."\n";
//echo "MySQL Version : ".$mysqlVersion."\n";
//echo "CiviCRM Version : ".$civicrmVersion."\n";
//echo "Drupal Version : ".$drupalVersion."\n";
return $returnString = "PHP Version:" . $PHPVersion . "<br>" . "MySQL Version:" . $mysqlVersion . "<br>" . "CiviCRM Version:" . $civicrmVersion . "<br>" . "Drupal Version:" . $drupalVersion . "<br>";
}
示例10: ovfImport
public function ovfImport($url, $xpath = false)
{
$this->url = $url;
$dom = new DomDocument();
$loaded = $dom->load($url);
if (!$loaded) {
return $loaded;
}
$xpath = new DomXPath($dom);
// register the namespace
$xpath->registerNamespace('envl', 'http://schemas.dmtf.org/ovf/envelope/1');
$vs_nodes = $xpath->query('//envl:VirtualSystem');
// selects all name element
$refs_nodes = $xpath->query('//envl:References');
// selects all name element
$disk_nodes = $xpath->query('//envl:DiskSection');
// selects all name element
$refs_nodes_0 = $refs_nodes->item(0);
$disk_nodes_0 = $disk_nodes->item(0);
$vs_nodes_0 = $vs_nodes->item(0);
if ($refs_nodes_0 && $disk_nodes_0 && $vs_nodes_0) {
$this->buildReferences($refs_nodes_0);
$this->buildDiskSection($disk_nodes_0);
$this->buildVirtualSystem($vs_nodes_0);
return true;
} else {
return false;
}
}
示例11: __construct
public function __construct()
{
if (!defined("WebOrbServicesPath")) {
$dom = new DomDocument();
$dom->load(WebOrb . "weborb-config.xml");
$servicePath = $dom->documentElement->getAttribute('servicePath');
define("WebOrbServicesPath", realpath(WebOrb . $servicePath) . DIRECTORY_SEPARATOR);
}
if (file_exists(WebOrbServicesPath . "Weborb/Examples/Security/datbase.db")) {
if (!($this->link = sqlite_open(WebOrbServicesPath . "Weborb/Examples/Security/datbase.db", 0666, $sqliteerror))) {
throw new Exception($sqliteerror);
}
} else {
if (!($this->link = sqlite_open(WebOrbServicesPath . "Weborb/Examples/Security/datbase.db", 0666, $sqliteerror))) {
throw new Exception($sqliteerror);
}
sqlite_query($this->link, "CREATE TABLE Security ( Id INT, UserName VARCHAR(20), Password VARCHAR(20), Role VARCHAR(20) )");
sqlite_query($this->link, "INSERT INTO Security (Id, UserName, Password, Role) VALUES ( 1, 'joe', 'flexrocks', 'examplesuser' )");
sqlite_query($this->link, "INSERT INTO Security (Id, UserName, Password, Role) VALUES ( 2, 'bob', 'weborb', 'administrator' )");
sqlite_query($this->link, "CREATE TABLE Products ( Id INT, Name VARCHAR(20), Price NUMERIC )");
sqlite_query($this->link, "INSERT INTO Products (Id, Name, Price) VALUES ( 1, 'Laptop', 499 )");
sqlite_query($this->link, "INSERT INTO Products (Id, Name, Price) VALUES ( 2, 'Mouse', 20 )");
sqlite_query($this->link, "INSERT INTO Products (Id, Name, Price) VALUES ( 3, 'Keyboard', 10 )");
}
}
示例12: handle
/**
* Handle provided directory
*
* Optionally an existing result file can be provided
*
* If a valid file could be generated the file name is supposed to be
* returned, otherwise return null.
*
* @param Project $project
* @param string $existingResult
*
* @return string
*/
public function handle(Project $project, $existingResult = null)
{
if (!isset($project->analyzers['pdepend'])) {
return;
}
$pdependResultFile = $project->dataDir . '/' . $project->analyzers['pdepend'];
$document = new \DomDocument();
$document->load($pdependResultFile);
$xPath = new \DomXPath($document);
foreach ($xPath->query('//package') as $packageNode) {
$packageCommits = 0;
foreach ($xPath->query('./class', $packageNode) as $classNode) {
$fileNode = $xPath->query('./file', $classNode)->item(0);
$file = $fileNode->getAttribute('name');
$classCommits = $this->countGitChangesPerFileRange($project, $file, $classNode->getAttribute('start'), $classNode->getAttribute('end'));
$packageCommits += $classCommits;
$classNode->setAttribute('commits', $classCommits);
foreach ($xPath->query('./method', $classNode) as $methodNode) {
$methodCommits = $this->countGitChangesPerFileRange($project, $file, $methodNode->getAttribute('start'), $methodNode->getAttribute('end'));
$methodNode->setAttribute('commits', $methodCommits);
}
}
$packageNode->setAttribute('commits', $packageCommits);
}
$document->save($pdependResultFile);
return null;
}
示例13: readDataBlock
protected function readDataBlock()
{
$v9a09b4dfda82e3e665e31092d1c3ec8d = DomDocument::load($this->file_path);
$this->offset = 0;
$this->complete = true;
return $v9a09b4dfda82e3e665e31092d1c3ec8d;
}
示例14: search
function search($query)
{
$this->url .= "&q=" . urlencode($query);
$xml = new \DomDocument();
$xml->load($this->url);
return $xml;
}
示例15: retrieve
function retrieve($caseType)
{
require_once 'CRM/Utils/String.php';
require_once 'CRM/Utils/Array.php';
// trim all spaces from $caseType
$caseType = str_replace('_', ' ', $caseType);
$caseType = CRM_Utils_String::munge(ucwords($caseType), '', 0);
if (!CRM_Utils_Array::value($caseType, self::$_xml)) {
if (!self::$_xml) {
self::$_xml = array();
}
// first check custom templates directory
$fileName = null;
$config = CRM_Core_Config::singleton();
if (isset($config->customTemplateDir) && $config->customTemplateDir) {
// check if the file exists in the custom templates directory
$fileName = implode(DIRECTORY_SEPARATOR, array($config->customTemplateDir, 'CRM', 'Case', 'xml', 'configuration', "{$caseType}.xml"));
}
if (!$fileName || !file_exists($fileName)) {
// check if file exists locally
$fileName = implode(DIRECTORY_SEPARATOR, array(dirname(__FILE__), 'xml', 'configuration', "{$caseType}.xml"));
if (!file_exists($fileName)) {
return false;
}
}
// read xml file
$dom = DomDocument::load($fileName);
$dom->xinclude();
self::$_xml[$caseType] = simplexml_import_dom($dom);
}
return self::$_xml[$caseType];
}