當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。