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


PHP DOMDocument::Load方法代码示例

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


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

示例1: loadFields

 /**
  * generate fields from services recursivly
  *
  * @param array   $map      map to add entries to
  * @param string  $ns       namespace
  * @param string  $bundle   bundle name
  * @param string  $doc      document name
  * @param boolean $embedded is this an embedded doc, further args are only for embeddeds
  * @param string  $name     name prefix of document the embedded field belongs to
  * @param string  $prefix   prefix to add to embedded field name
  *
  * @return void
  */
 private function loadFields(&$map, $ns, $bundle, $doc, $embedded = false, $name = '', $prefix = '')
 {
     if (strtolower($ns) === 'gravitondyn') {
         $ns = 'GravitonDyn';
     }
     $finder = new Finder();
     $files = $finder->files()->in(implode('/', [__DIR__, '..', '..', '..', '..', ucfirst($ns), ucfirst($bundle) . 'Bundle', 'Resources', 'config', 'doctrine']))->name(ucfirst($doc) . '.mongodb.xml');
     // we only want to find exactly one file
     if ($files->count() != 1) {
         return;
     }
     // array_pop would have been nice but won't work here, some day I'll look into iterators or whatnot
     $file = null;
     foreach ($files as $fileObject) {
         $file = $fileObject->getRealPath();
     }
     if (!file_exists($file)) {
         return;
     }
     $dom = new \DOMDocument();
     $dom->Load($file);
     $xpath = new \DOMXPath($dom);
     $xpath->registerNamespace('doctrine', 'http://doctrine-project.org/schemas/odm/doctrine-mongo-mapping');
     $this->loadFieldsFromDOM($map, $xpath, $ns, $bundle, $doc, $embedded, $name, $prefix);
 }
开发者ID:smoskalenko,项目名称:graviton,代码行数:38,代码来源:LoadFieldsTrait.php

示例2: add_to_xml

function add_to_xml($file, $title, $author, $price, $rating)
{
    $doc = new DOMDocument();
    $doc->Load($file);
    $list = $doc->getElementsByTagName("list")->item(0);
    $newid = (int) $list->getElementsByTagName("lastindex")->item(0)->textContent + 1;
    //echo $newid;
    $lastindex = $list->getElementsByTagName("lastindex")->item(0);
    $list->removeChild($lastindex);
    $newLastIndex = $doc->createElement("lastindex");
    $newLastIndex->appendChild($doc->createTextNode($newid));
    $list->appendChild($newLastIndex);
    //$list->getElementsByTagName("lastindex")->item(0)->appendChild($doc->createTextNode($newid));
    $newElement = $doc->createElement("item");
    $list->appendChild($newElement);
    $idd = $doc->createElement("id");
    $idd->appendChild($doc->createTextNode($newid));
    $newElement->appendChild($idd);
    $t = $doc->createElement("title");
    $t->appendChild($doc->createTextNode($title));
    $newElement->appendChild($t);
    $au = $doc->createElement("author");
    $au->appendChild($doc->createTextNode($author));
    $newElement->appendChild($au);
    $pri = $doc->createElement("price");
    $pri->appendChild($doc->createTextNode($price));
    $newElement->appendChild($pri);
    $ra = $doc->createElement("rating");
    $ra->appendChild($doc->createTextNode($rating));
    $newElement->appendChild($ra);
    $doc->save($file);
}
开发者ID:uhdyi,项目名称:blacklist,代码行数:32,代码来源:add_to_xml.php

示例3: DOMDocument

 function __construct()
 {
     global $xml, $dom, $localhost, $mysql_user, $mysql_password, $db;
     $xml = "config.xml";
     $dom = new DOMDocument();
     $dom->Load($xml);
     $localhost = $dom->getElementsByTagName('localhost')->item(0)->textContent;
     $mysql_user = $dom->getElementsByTagName('mysql_user')->item(0)->textContent;
     $mysql_password = $dom->getElementsByTagName('mysql_password')->item(0)->textContent;
     $db = $dom->getElementsByTagName('db')->item(0)->textContent;
     $query = "";
     $result = "";
 }
开发者ID:rjdl,项目名称:Citas,代码行数:13,代码来源:mysql.php

示例4: install

 function install()
 {
     $doc = new DOMDocument();
     $doc->Load(dirname(__FILE__) . '/../module.xml');
     $xpath = new DOMXPath($doc);
     $xpath->registerNamespace('jelix', "http://jelix.org/ns/module/1.0");
     $query = "//jelix:module/jelix:info/jelix:version/text()";
     $entries = $xpath->evaluate($query);
     $version = $entries->item(0)->nodeValue;
     $ini = new jIniFileModifier(jApp::configPath() . 'defaultconfig.ini.php');
     $ini->setValue('version', $version, 'havefnubb');
     $ini->save();
 }
开发者ID:havefnubb,项目名称:havefnubb,代码行数:13,代码来源:upgrade_finale.php

示例5: validateFileIntegrity

 public function validateFileIntegrity($attribute, $file, $parameters)
 {
     if ($file instanceof \Symfony\Component\HttpFoundation\File\UploadedFile) {
         switch ($file->getClientMimeType()) {
             // For some reason, MP3 files routinely get scanned as octet-streams.
             // Attempt to evaluate it as music or a video.
             case "application/octet-stream":
             case "audio/mpeg":
             case "audio/mp3":
             case "video/mp4":
             case "video/flv":
             case "video/webm":
                 return FileStorage::probe($file);
             case "application/x-shockwave-flash":
                 // This is much slower than exif_imagetype but much more reliable with flash files.
                 return getimagesize($file->getPathname())['mime'] == "application/x-shockwave-flash";
             case "image/x-ms-bmp":
                 return exif_imagetype($file->getPathname()) == IMAGETYPE_BMP;
             case "image/gif":
                 return exif_imagetype($file->getPathname()) == IMAGETYPE_GIF;
             case "image/jpeg":
             case "image/jpg":
                 return exif_imagetype($file->getPathname()) == IMAGETYPE_JPEG;
             case "image/png":
                 return exif_imagetype($file->getPathname()) == IMAGETYPE_PNG;
             case "image/svg":
             case "image/svg+xml":
                 try {
                     $dom = new \DOMDocument();
                     $dom->Load($file->getPathname());
                     if ($dom->getElementsByTagName('script')->length > 0) {
                         return false;
                     }
                     return $dom->saveXML() !== false;
                 } catch (\Exception $error) {
                     return false;
                 }
                 // Things we allow but can't validate.
             // Things we allow but can't validate.
             case "application/epub+zip":
             case "application/pdf":
                 return true;
             default:
                 return false;
         }
     }
     return false;
     dd($value);
 }
开发者ID:nitogel,项目名称:infinity-next,代码行数:49,代码来源:FileValidator.php

示例6: doTest

 public function doTest($xmlPath, $type)
 {
     echo "\tTesting File [{$xmlPath}]\n";
     $serviceUrl = $this->client->getConfig()->serviceUrl;
     $xsdPath = "{$serviceUrl}/api_v3/index.php/service/schema/action/serve/type/{$type}";
     //		libxml_use_internal_errors(true);
     //		libxml_clear_errors();
     $doc = new DOMDocument();
     $doc->Load($xmlPath);
     //Validate the XML file against the schema
     if (!$doc->schemaValidate($xsdPath)) {
         $description = kXml::getLibXmlErrorDescription(file_get_contents($xmlPath));
         $this->fail("Type [{$type}] File [{$xmlPath}]: {$description}");
     }
 }
开发者ID:EfncoPlugins,项目名称:Media-Management-based-on-Kaltura,代码行数:15,代码来源:SchemaServiceTestValidate.php

示例7: getTree

 /**
  * retrieves the tree
  * 
  * @param boolean   clone true if tree has to be cloned
  * @return DOMXpath tree
  */
 public function getTree($clone = false, $type = Tree::TREE_DEFAULT)
 {
     /*
     TODO dit is de werkwijze van een database tree
     kijk of xml bestand bestaat en geef terug
     haal tabel op en creer xml met dom
     schrijf xml weg naar bestand
     bij een wijziging, gooi het xml bestand weg
     voer AdminTree xml functies uit (in standaard abstracte klasse..
     
     
     tree is abstract en gebruikt xml functies, implementatie gebruikt eventueel een dbConnector object.
     */
     if ($type == Tree::TREE_DEFAULT) {
         if (isset($this->tree)) {
             if (!$clone) {
                 return $this->tree;
             }
             $doc = clone $this->doc;
             return new DOMXPath($doc);
         }
     } elseif ($type == Tree::TREE_ORIGINAL) {
         if (isset($this->treeOriginal)) {
             if (!$clone) {
                 return $this->treeOriginal;
             }
             $doc = clone $this->doc;
             return new DOMXPath($doc);
         }
     }
     $doc = new DOMDocument('1.0', 'iso-8859-1');
     // We don't want to bother with white spaces
     $doc->preserveWhiteSpace = false;
     $doc->Load($this->fileName);
     $this->tree = new DOMXPath($doc);
     // create a backup of tree
     $this->treeOriginal = new DOMXpath(clone $doc);
     $this->filterTree();
     $this->doc = $doc;
     if ($type == Tree::TREE_ORIGINAL) {
         return $this->treeOriginal;
     } else {
         return $this->tree;
     }
 }
开发者ID:rverbrugge,项目名称:dif,代码行数:51,代码来源:AdminTree.php

示例8: DOMDocument

<?php

$doc = new DOMDocument();
$doc->preserveWhiteSpace = false;
$doc->Load('view.html');
$titlenode = $doc->createTextNode("Like this");
$xpath = new DOMXPath($doc);
$xpath->registerNamespace("h", "http://www.w3.org/1999/xhtml");
$query = "//h:*[@data-xp='title']/comment()";
$entries = $xpath->query($query);
foreach ($entries as $entry) {
    $entry->parentNode->replaceChild($titlenode, $entry);
}
echo $doc->saveXML();
?>

<?php 
//
//// Facade
//
//$doc = new DOMDocument;
//$doc->preserveWhiteSpace = true;
//$doc->loadHTMLFile('page/index.html');
//$xpath = new DOMXPath($doc);
//$xpath->registerNamespace("h","http://www.w3.org/1999/xhtml");
//
//$queryConnexion="//*[@id='connexion']"; //*[@id="connexion"]
//
//$entries = $xpath->query($queryConnexion);
//
//$docConnex = new DOMDocument;
开发者ID:Rom1deTroyes,项目名称:Afpa2015,代码行数:31,代码来源:ControlTemplateXpath.php

示例9: evaluateXML

 function evaluateXML($xpath_query = '', $url = '')
 {
     if (empty($url)) {
         $url = $this->config->xml_data_path;
     }
     $doc = new DOMDocument();
     $doc->preserveWhiteSpace = false;
     $doc->Load($url);
     $xpath = new DOMXPath($doc);
     return $xpath->evaluate($xpath_query);
     //Array
 }
开发者ID:neelam,项目名称:Test,代码行数:12,代码来源:common_class.php

示例10: fwrite

    }
    fwrite($fs, ');');
}
if (isset($_POST['check_struct_files'])) {
    getStructFilesGIT($branch, $output, $info);
    $i = 0;
    $dom = new DOMDocument();
    $dom->preserveWhiteSpace = false;
    $dom->substituteEntities = true;
    print "URL: " . $info;
    print "<br>Branch: " . $branch . "<br>";
    foreach ($output as $arr) {
        $i++;
        $xmlfile = 'xml/' . $arr[0] . '.xml';
        if (file_exists($xmlfile)) {
            $dom->Load($xmlfile);
            $tt = $dom->getElementsByTagName('file')->item(0);
            $arr["L"] = $DBCfmt[$arr[0]];
            if ($arr["L"] != $arr[1]) {
                print_r($arr);
            }
        } else {
        }
    }
}
if (isset($_POST['dbclayout'])) {
    $b_dbc = getListFiles('dbc/', 'dbc');
    $subdirs = getListSubdirs('dbc/');
    $f_w = fopen("dbclayout.xml", 'wb');
    fwrite($f_w, "<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n");
    fwrite($f_w, "<DBCFilesClient>\r\n");
开发者ID:Refuge89,项目名称:World-of-Warcraft-Trinity-Core-MaNGOS,代码行数:31,代码来源:check.php

示例11: DOMDocument

// connect to the database
include '../../config/config.php';
// confirm that the 'id' variable has been set
if (isset($_POST['category_id']) && is_numeric($_POST['category_id'])) {
    // get the 'id' variable from the URL
    $category_id = $_POST['category_id'];
    $category_name = $_POST['category_name'];
    $category_details = $_POST['category_details'];
    // update record from database
    $sql = "UPDATE tblcategory set category_name ='" . $category_name . "',category_details ='" . $category_details . "' WHERE category_id = '" . $category_id . "' LIMIT 1";
    $conn->query($sql);
    if ($conn->query($sql)) {
        $xml = new DOMDocument("1.0", "utf-8");
        $xml->formatOutput = true;
        $xml->preserveWhiteSpace = false;
        $xml->Load('../../data/category.xml');
        $root = $xml->getElementsByTagName('categories')->item(0);
        $categories = $root->getElementsByTagName('category');
        foreach ($categories as $category) {
            if ($category->getElementsByTagName('id')->item(0)->nodeValue == $category_id) {
                $category->getElementsByTagName('name')->item(0)->nodeValue = $category_name;
                $category->getElementsByTagName('details')->item(0)->nodeValue = $category_details;
            }
        }
        $xml->Save('../../data/category.xml');
        $return = array("status" => "200", "message" => "Success");
        echo json_encode($return);
    } else {
        echo "ERROR: could not prepare SQL statement.";
    }
    $conn->close();
开发者ID:vistajess,项目名称:playgroundz,代码行数:31,代码来源:updateCategory.php

示例12: DOMDocument

        echo $message;
    }
}
//you get the following information for each file:
// $_FILES['field_name']['name']
// $_FILES['field_name']['size']
// $_FILES['field_name']['type']
// $_FILES['field_name']['tmp_name']
// =============================================================================
// ---------------------------- END OF UPLOAD ---------------------------------
// =============================================================================
include '../../config/config.php';
$xml = new DOMDocument("1.0", "utf-8");
$xml->formatOutput = true;
$xml->preserveWhiteSpace = false;
$xml->Load('../../data/products.xml');
// $sql = "SELECT Auto_increment FROM information_schema.tables WHERE table_name='tblproduct'";
// $query = mysqli_query($conn, $sql);
// $result = mysqli_fetch_row($query);
// $id = $result[0];
$name = $_POST['product_name'];
$description = $_POST['description'];
$quantity = $_POST['quantity'];
$price = $_POST['price'];
$product_image = basename($_FILES['product_image']['name']);
$category = $_POST['category_id'];
$tags_array_string = $_POST['tags_array'];
$tags_array_id = [];
$tags_sql = '';
$stmt = $conn->prepare("INSERT INTO tblproduct (product_name,category_id,description,quantity,price,product_image) VALUES(?,?,?,?,?,?)");
$stmt->bind_param("ssssss", $name, $category, $description, $quantity, $price, $product_image);
开发者ID:vistajess,项目名称:playgroundz,代码行数:31,代码来源:addProduct.php

示例13: array

// confirm that the 'id' variable has been set
if (isset($_GET['id']) && is_numeric($_GET['id'])) {
    // get the 'id' variable from the URL
    $id = $_GET['id'];
    // delete record from database
    if ($stmt = $conn->prepare("DELETE FROM tbluser WHERE userID = ? LIMIT 1")) {
        $stmt->bind_param("s", $id);
        $stmt->execute();
        $stmt->close();
        $return = array("status" => "200", "message" => "Success");
        echo json_encode($return);
        // delete to XML FILE
        $xml = new DOMDocument("1.0", "utf-8");
        $xml->formatOutput = true;
        $xml->preserveWhiteSpace = false;
        $xml->Load('../../data/users.xml');
        $root = $xml->getElementsByTagName('users')->item(0);
        $users = $root->getElementsByTagName('user');
        foreach ($users as $user) {
            $current_id = $user->getElementsByTagName('id')->item(0)->nodeValue;
            if ($current_id == $id) {
                $root->removeChild($user);
            }
        }
        $xml->Save('../../data/users.xml');
    } else {
        echo "ERROR: could not prepare SQL statement.";
    }
    $conn->close();
    // redirect user after delete is successful
    // header("Location: ../user_list.php");
开发者ID:vistajess,项目名称:playgroundz,代码行数:31,代码来源:deleteUser.php

示例14: die

<?php

// Step 2: Find <div class="note"> and wrap in link if found wrap in href from child edittopiclink
// This doesn't work when the DOCTYPE declaration is present, so strip that line out of the html file before handing it over to this script
if (!isset($argv) || $argc < 3) {
    die('Pass input and output file names as arguments');
}
$doc = new DOMDocument();
$doc->preserveWhiteSpace = true;
$doc->Load($argv[1]);
$xpath = new DOMXPath($doc);
$xpath->registerNamespace("x", "http://www.w3.org/1999/xhtml");
// The Sections that SKynet produces (Invalid or Unwritten topics) have the class "clicknode"
$classname = "clicknode";
$query = "//*[contains(concat(' ', normalize-space(@class), ' '), ' {$classname} ')]";
$clicknodes = $xpath->query($query);
// debug counters
$clickablecount = 0;
$linkcount = 0;
foreach ($clicknodes as $clicknode) {
    //  $editTopicLinkQuery = ".//x:a";
    //  $editTopicLinkQuery = ".//*[contains(concat(' ', normalize-space(@class), ' '), ' edittopiclink ')]";
    $editTopicLinkQuery = ".//x:a[@class='edittopiclink']";
    $editLinks = $xpath->query($editTopicLinkQuery, $clicknode);
    $clickableQuery = ".//*[contains(concat(' ', normalize-space(@class), ' '), ' clickable ')]";
    $clickables = $xpath->query($clickableQuery, $clicknode);
    $clickablecount = $clickablecount + $clickables->length;
    $linkcount = $linkcount + $editLinks->length;
    if ($clickables->length == 1) {
        if ($editLinks->length == 1) {
            /*
开发者ID:hugoapp,项目名称:fudcon-docs-hack,代码行数:31,代码来源:makeclickable.php

示例15: readManifest

 static function readManifest($theme)
 {
     $themesInfo = array();
     $doc = new DOMDocument();
     $doc->Load(jApp::varPath('/themes/' . $theme . '/theme.xml'));
     $xpath = new DOMXPath($doc);
     $xpath->registerNamespace(self::$ns, self::$nsURL);
     $query = '//' . self::$ns . ':info/@id';
     $entries = $xpath->query($query);
     $themeId = $entries->item(0)->nodeValue;
     $query = '//' . self::$ns . ':info/@name';
     $entries = $xpath->query($query);
     $themeName = $entries->item(0)->nodeValue;
     $query = '//' . self::$ns . ':info/@createdate';
     $entries = $xpath->query($query);
     $themeDateCreated = $entries->item(0)->nodeValue;
     $query = '//' . self::$ns . ':version/@stability';
     $entries = $xpath->query($query);
     $versionStability = $entries->item(0)->nodeValue;
     $query = '//' . self::$ns . ':version/text()';
     $entries = $xpath->query($query);
     $versionNumber = $entries->item(0)->nodeValue;
     $label = 'N/A';
     $query = '//' . self::$ns . ":label[@lang='" . jApp::config()->locale . "']/text()";
     $entries = $xpath->query($query);
     if (!is_null($entries->item(0))) {
         $label = $entries->item(0)->nodeValue;
     }
     $desc = 'N/A';
     $query = '//' . self::$ns . ":description[@lang='" . jApp::config()->locale . "']/text()";
     $entries = $xpath->query($query);
     if (!is_null($entries->item(0))) {
         $desc = $entries->item(0)->nodeValue;
     }
     $creators = array();
     $query = '//' . self::$ns . ':creator';
     $entries = $xpath->query($query);
     foreach ($entries as $entry) {
         $creatorName = '';
         $creatorNickname = '';
         $creatorEmail = '';
         $creatorActive = '';
         if ($entry->hasAttribute('name')) {
             $creatorName = $entry->getAttribute('name');
         } else {
             die("fichier theme.xml invalide");
         }
         if ($entry->hasAttribute('nickname')) {
             $creatorNickname = $entry->getAttribute('nickname');
         }
         if ($entry->hasAttribute('email')) {
             $creatorEmail = $entry->getAttribute('email');
         }
         if ($entry->hasAttribute('active')) {
             $creatorActive = $entry->getAttribute('active');
         }
         $creators[] = array('name' => $creatorName, 'nickname' => $creatorNickname, 'email' => $creatorEmail, 'active' => $creatorActive);
     }
     $query = '//' . self::$ns . ':notes';
     $entries = $xpath->query($query);
     $notes = 'N/A';
     if (!is_null($entries->item(0))) {
         $notes = $entries->item(0)->nodeValue;
     }
     $updateURL = '';
     $query = '//' . self::$ns . ':updateURL/text()';
     $entries = $xpath->query($query);
     $updateURL = $entries->item(0)->nodeValue;
     $homepageURL = '';
     $query = '//' . self::$ns . ':homepageURL/text()';
     $entries = $xpath->query($query);
     $homepageURL = $entries->item(0)->nodeValue;
     $licence = '';
     $query = '//' . self::$ns . ':licence/text()';
     $entries = $xpath->query($query);
     $licence = $entries->item(0)->nodeValue;
     $licenceURL = '';
     $query = '//' . self::$ns . ':licence/@URL';
     $entries = $xpath->query($query);
     $licenceURL = $entries->item(0)->nodeValue;
     $copyright = '';
     $query = '//' . self::$ns . ':copyright/text()';
     $entries = $xpath->query($query);
     $copyright = $entries->item(0)->nodeValue;
     $themesInfo = array('name' => strtolower($themeName), 'id' => $themeId, 'version' => $versionStability . ' ' . $versionNumber, 'dateCreate' => $themeDateCreated, 'label' => $label, 'desc' => $desc, 'creators' => $creators, 'updateURL' => $updateURL, 'homepageURL' => $homepageURL, 'licence' => $licence, 'licenceURL' => $licenceURL, 'copyright' => $copyright);
     return $themesInfo;
 }
开发者ID:havefnubb,项目名称:havefnubb,代码行数:87,代码来源:themes.class.php


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