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


PHP DomDocument::Load方法代码示例

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


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

示例1: buildModel

 public function buildModel($model)
 {
     try {
         $dom = new DomDocument();
         $dom->Load($this->loadModel($model));
         $rooms_base = $dom->getElementsByTagName("roomdata");
         foreach ($rooms_base as $rooms_bases) {
             $roomtypes = $rooms_bases->getElementsByTagName("roomtype")->item(0)->nodeValue;
             $caption = $rooms_bases->getElementsByTagName("caption")->item(0)->nodeValue;
             $model_name = $rooms_bases->getElementsByTagName("model_name")->item(0)->nodeValue;
             $description = $rooms_bases->getElementsByTagName("description")->item(0)->nodeValue;
             if ($this->createRooms($roomtypes, $caption, $username, $description, $model_name)) {
                 echo 'Done rooms<br/>';
             }
         }
         foreach ($dom->getElementsByTagName("roomitem") as $room_items) {
             foreach ($room_items->getElementsByTagName("item") as $item) {
                 $base_item = $item->getElementsByTagName("base_item")->item(0)->nodeValue;
                 $x = $item->getElementsByTagName("x")->item(0)->nodeValue;
                 $y = $item->getElementsByTagName("y")->item(0)->nodeValue;
                 $z = $item->getElementsByTagName("z")->item(0)->nodeValue;
                 $rot = $item->getElementsByTagName("rot")->item(0)->nodeValue;
                 $coord = array('x' => $x, 'y' => $y, 'z' => $z);
                 if ($this->addItemsToRooms($user_id, null, $base_item, $coord, $rot)) {
                     echo 'Done ' . $base_item . '<br/>';
                 }
             }
         }
     } catch (Exception $e) {
         echo $e->getMessage();
     }
 }
开发者ID:habb0,项目名称:HabboPHP,代码行数:32,代码来源:rooms.class.php

示例2: draw_svg

function draw_svg($pie_id, $base_name, $args)
{
    global $output_dir;
    global $svg_template;
    global $bg_schemes;
    $bar_start = 48;
    $bar_end = 312.4;
    $bar_len = $bar_end - $bar_start;
    $svg_output = $output_dir . $base_name . '.svg';
    if (file_exists($svg_output)) {
        return $svg_output;
    }
    // Parse
    $xdoc = new DomDocument();
    $xdoc->Load($svg_template);
    $xp = new DomXPath($xdoc);
    // Get progress from DB
    $result = pg_query("SELECT state FROM pieces WHERE pie = " . $pie_id);
    $states = pg_fetch_all_columns($result, 0);
    $progress = array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
    $full_sum = 9 * count($states);
    $current_sum = 0;
    foreach ($states as $st) {
        $progress[$st]++;
        $current_sum += $st;
    }
    // Calculate bars positions and widths
    $offset = $bar_start;
    $step = $bar_len / count($states);
    for ($i = 0; $i <= 9; $i++) {
        $elem = find_by_id($xp, 'bar_' . $i);
        $elem->setAttribute('x', $offset);
        $elem->setAttribute('width', $step * $progress[$i]);
        $offset += $step * $progress[$i];
    }
    // Set percent
    $percent = round($current_sum / $full_sum * 100);
    find_by_id($xp, 'percent-fg')->nodeValue = $percent . '%';
    // Set BG color gradient;
    $current_bg_scheme = $bg_schemes['middle'];
    if ($progress[9] / count($states) > 0.6) {
        $current_bg_scheme = $bg_schemes['high'];
    } else {
        if ($progress[0] / count($states) > 0.6) {
            $current_bg_scheme = $bg_schemes['low'];
        }
    }
    find_by_id($xp, 'bg-grd-start')->setAttribute('style', 'stop-color:#' . $current_bg_scheme[0] . ';stop-opacity:1');
    find_by_id($xp, 'bg-grd-stop')->setAttribute('style', 'stop-color:#' . $current_bg_scheme[1] . ';stop-opacity:1');
    // Save it to file
    if (($fd = fopen($svg_output, 'w')) === false) {
        throw new Exception("Cant open SVG file for saving");
    }
    fwrite($fd, $xdoc->saveXML());
    fclose($fd);
    return $svg_output;
}
开发者ID:nicevoice,项目名称:MapCraft,代码行数:57,代码来源:progress1.php

示例3: validate

function validate($xml, $schema)
{
    $doc = new DomDocument();
    $doc->Load($xml);
    if (@$doc->schemaValidate($schema)) {
        printf('%s is valid against %s' . "\n", $xml, $schema);
    } else {
        printf('!!! %s is not valid against %s' . "\n", $xml, $schema);
    }
}
开发者ID:marekpribyl,项目名称:xml-feeds-schemas,代码行数:10,代码来源:validate.php

示例4: get_youtube_subscriber_count

function get_youtube_subscriber_count($youtubeID)
{
    $subs_record = 'ytsubs_' . '_' . $youtubeID . '_' . 60 * 60 * 6;
    $cached = get_transient($subs_record);
    if ($cached !== false) {
        return $cached;
    } else {
        $xdoc = new DomDocument();
        $xdoc->Load("http://gdata.youtube.com/feeds/api/users/{$youtubeID}");
        $youtubeStats = $xdoc->getElementsByTagName('statistics')->item(0);
        $return = $youtubeStats->getAttribute('subscriberCount');
        $count = number_format($return);
        set_transient($subs_record, $count, 60 * 60 * 6);
    }
    $formatted_count = sf_social_number_format($count);
    return $formatted_count;
}
开发者ID:nilmadhab,项目名称:webtutplus,代码行数:17,代码来源:functions.php

示例5: add_xml_observations

function add_xml_observations()
{
    global $baseURL, $entryMessage, $objSession, $mailTo, $mailFrom, $loggedUser, $objConstellation, $objObject, $objCatalog, $objLocation, $objInstrument, $objFilter, $objEyepiece, $objLens, $objDatabase, $objObserver, $objObservation;
    if ($_FILES['xml']['tmp_name'] != "") {
        $xmlfile = $_FILES['xml']['tmp_name'];
    } else {
        $entryMessage .= LangXMLError3;
        $_GET['indexAction'] = "add_xml";
        return;
    }
    // Make a DomDocument from the file.
    $dom = new DomDocument();
    $xmlfile = realpath($xmlfile);
    // Load the xml document in the DOMDocument object
    $dom->Load($xmlfile);
    $searchNode = $dom->getElementsByTagName("observations");
    $version = $searchNode->item(0)->getAttribute("version");
    if ($version == "2.0" || $version == "2.1") {
    } else {
        $entryMessage .= LangXMLError1;
        $_GET['indexAction'] = "add_xml";
        return;
    }
    // Use the correct schema definition to check the xml file.
    $xmlschema = str_replace(' ', '/', $searchNode->item(0)->getAttribute("xsi:schemaLocation"));
    $xmlschema = $baseURL . "xml/oal21/oal21.xsd";
    // Validate the XML file against the schema
    if ($dom->schemaValidate($xmlschema)) {
        // The XML file is valid. Let's start reading in the file.
        // Only 2.0 and 2.1 files!
        // Check the observers -> In OpenAstronomyLog 2.0 the deepskylog_id is also added
        $searchNode = $dom->getElementsByTagName("observers");
        $observer = $searchNode->item(0)->getElementsByTagName("observer");
        $observerArray = array();
        $id = "";
        foreach ($observer as $observer) {
            $tmpObserverArray = array();
            // Get the id and the name of the observers in the comast file
            $comastid = $observer->getAttribute("id");
            $name = htmlentities($observer->getElementsByTagName("name")->item(0)->nodeValue, ENT_COMPAT, "UTF-8", 0);
            $tmpObserverArray['name'] = $name;
            $surname = htmlentities($observer->getElementsByTagName("surname")->item(0)->nodeValue, ENT_COMPAT, "UTF-8", 0);
            $tmpObserverArray['surname'] = $surname;
            if ($observer->getElementsByTagName("fstOffset")->item(0)) {
                $fstOffset[$comastid] = $observer->getElementsByTagName("fstOffset")->item(0)->nodeValue;
            } else {
                $fstOffset[$comastid] = 0.0;
            }
            $observerid = $observer->getElementsByTagName("account");
            $obsid = "";
            foreach ($observerid as $observerid) {
                if ($observerid->getAttribute("name") == "www.deepskylog.org") {
                    $obsid = $observerid->nodeValue;
                }
            }
            // Get the name of the observer which is logged in in DeepskyLog
            $deepskylog_username = $objObserver->getObserverProperty($_SESSION['deepskylog_id'], 'firstname') . " " . $objObserver->getObserverProperty($_SESSION['deepskylog_id'], 'name');
            if ($obsid != "") {
                if ($obsid == $_SESSION['deepskylog_id']) {
                    $id = $comastid;
                }
            } else {
                if ($deepskylog_username == $name . " " . $surname) {
                    $id = $comastid;
                }
            }
            $observerArray[$comastid] = $tmpObserverArray;
        }
        if ($id == "") {
            $entryMessage .= LangXMLError2 . $deepskylog_username . LangXMLError2a;
            $_GET['indexAction'] = "add_xml";
            return;
        } else {
            $objObserver->setObserverProperty($_SESSION['deepskylog_id'], 'fstOffset', $fstOffset[$id]);
        }
        $targets = $dom->getElementsByTagName("targets");
        $target = $targets->item(0)->getElementsByTagName("target");
        $targetArray = array();
        foreach ($target as $target) {
            $targetInfoArray = array();
            $targetid = $target->getAttribute("id");
            $targetInfoArray["name"] = $target->getElementsByTagName("name")->item(0)->nodeValue;
            $aliases = $target->getElementsByTagName("alias");
            $aliasesArray = array();
            $cnt = 0;
            foreach ($aliases as $aliases) {
                $aliasesArray["alias" . $cnt] = $aliases->nodeValue;
                $cnt = $cnt + 1;
            }
            // Check if the datasource is defined. If this is the case, get it. Otherwise, set to OAL
            if ($target->getElementsByTagName("datasource")->item(0)) {
                $targetInfoArray["datasource"] = $target->getElementsByTagName("datasource")->item(0)->nodeValue;
            } else {
                $targetInfoArray["datasource"] = "OAL";
            }
            $valid = true;
            // Get the type
            if ($target->getAttribute("xsi:type")) {
                $type = $target->getAttribute("xsi:type");
                $next = 1;
//.........这里部分代码省略.........
开发者ID:rolfvandervleuten,项目名称:DeepskyLog,代码行数:101,代码来源:add_xml_observations.php

示例6: DomDocument

<?php

// set MIME type
header("Content-type: text/html");
$st = $_GET['st'];
$url = "http://api.bart.gov/api/etd.aspx?cmd=etd&orig={$st}&key=MW9S-E7SL-26DU-VV8V";
$doc = new DomDocument();
$doc->validateOnParse = true;
$doc->Load($url);
$s = simplexml_import_dom($doc);
print "<b>BART departures-" . $s->station->name . "</b></br>";
print "<b>" . $s->date . "</b>&nbsp;&nbsp;";
print "<b>" . $s->time . "</b></br></br>";
$r = $s->station;
foreach ($r->etd as $item) {
    print '<b>' . $item->abbreviation . '</b></br>';
    foreach ($item->estimate as $est) {
        print 'platform' . $est->platform . '&nbsp;&nbsp;&nbsp;';
        print '<span>' . $est->minutes . '&nbsp;min</span>&nbsp;';
        print '<span style="background-color:' . $est->hexcolor . ';">(' . $est->length . '&nbsp;car)</span></br>';
    }
    print '</br>';
}
开发者ID:tanmoy1234,项目名称:cs75,代码行数:23,代码来源:info.php

示例7: DomDocument

<?php

$doc = new DomDocument();
$doc->validateOnParse = true;
$doc->Load('shopmenu.xml');
$s = simplexml_import_dom($doc);
$total = $_SESSION['t'];
$items = array();
$items = $_SESSION['it'];
foreach ($s->salads->salad as $salad) {
    if (isset($_GET[(string) $salad['name']])) {
        if (isset($_GET[(string) $salad['name'] . "type"])) {
            if ($_GET[(string) $salad['name'] . "type"] == $salad->price[0]) {
                $str = "small";
            } else {
                $str = "large";
            }
            $total = $total + (double) $_GET[(string) $salad['name'] . "type"];
            array_push($items, (string) $salad['name'] . " salad-" . $str);
        } else {
            $total = $total + (double) $salad->price[0];
            array_push($items, (string) $salad['name'] . " salad-small");
        }
    }
}
$_SESSION['t'] = $total;
$_SESSION['it'] = $items;
?>
<table width=100% cellspacing="50">
    <tr>
    <td class="box" weight=.7>
开发者ID:tanmoy1234,项目名称:cs75,代码行数:31,代码来源:salads.php

示例8: fwrite

   $dom->formatOutput = true;
   $dom->loadXML(str_replace(array("\n", "\r"), "", utf8_encode($xml->asXML())));
   fwrite($toot, ($dom->saveXML()));
   */
 // Kirjoitetaaan XML ja tehdään UTF8 encode
 fwrite($toot, str_replace(chr(10), "", utf8_encode($xml->asXML())));
 fclose($toot);
 // Tehdään vielä tässä vaiheessa XML validointi, vaikka ainesto onkin jo tehty. :(
 libxml_use_internal_errors(true);
 $xml_virheet = "";
 $xml_domdoc = new DomDocument();
 $xml_file = $pankkitiedostot_polku . $kaunisnimi;
 $xml_schema = "{$pupe_root_polku}/datain/pain.001.001.02.xsd";
 // Tämä tiedosto lähetetään pankkiin!
 $pankkiyhteys_tiedosto = $kaunisnimi;
 $xml_domdoc->Load($xml_file);
 if (!$xml_domdoc->schemaValidate($xml_schema)) {
     echo "<font class='message'>SEPA-aineistosta löytyi vielä seuraavat virheet, aineisto saattaa hylkääntyä pankissa!</font><br><br>";
     $all_errors = libxml_get_errors();
     foreach ($all_errors as $error) {
         echo "<font class='info'>{$error->message}</font><br>";
         $xml_virheet .= "{$error->message}\n";
     }
     echo "<br>";
     // Lähetetään viesti adminille!
     mail($yhtiorow['admin_email'], mb_encode_mimeheader($yhtiorow['nimi'] . " - SEPA Error", "ISO-8859-1", "Q"), $xml_virheet . "\n", "From: " . mb_encode_mimeheader($yhtiorow["nimi"], "ISO-8859-1", "Q") . " <{$yhtiorow['postittaja_email']}>\n", "-f {$yhtiorow['postittaja_email']}");
 }
 echo "<tr><th>" . t("Tallenna aineisto") . "</th>";
 echo "<form method='post' class='multisubmit'>";
 echo "<input type='hidden' name='tee' value='lataa_tiedosto'>";
 echo "<input type='hidden' name='kaunisnimi' value='{$kaunisnimi}'>";
开发者ID:Hermut,项目名称:pupesoft,代码行数:31,代码来源:sepa.php

示例9: exec

             $noftf = "_noftf";
         } else {
             $noftf = "";
         }
         exec("cp Logbook-A7-_dwustronny_by_rushcore_page{$page}{$noftf}.svg work/{$shortname}.svg");
     }
 }
 replace_text_in_file("work/{$shortname}.svg", "logo.png", "/tmp/" . $shortname . "2.{$ext}");
 replace_text_in_file("work/{$shortname}.svg", "logo2.png", "/tmp/" . $shortname . "3.{$ext2}");
 $cachename = substr($_POST['cache_name'], 0, 80);
 $coords = substr($_POST['coords'], 0, 80);
 $nick = substr($_POST['nick'], 0, 80);
 $email = substr($_POST['email'], 0, 80);
 $svg = new DomDocument();
 $svg->validateOnParse = true;
 $svg->Load("work/{$shortname}.svg");
 if ($_POST['noborders'] && !($i % 2)) {
     for ($f = 1; $f <= 4; ++$f) {
         $elem = $svg->getElementById('frame' . $f);
         if ($elem) {
             $elem->setAttribute("style", "fill:none;stroke-opacity: 0");
         }
     }
 }
 $elem = $svg->getElementById('titlelogo');
 $mod = 0;
 if ($elem) {
     $elem->setAttribute("height", $elem->getAttribute("height") + (double) $_POST['h1']);
     $elem->setAttribute("width", $elem->getAttribute("width") + (double) $_POST['w1']);
     $elem->setAttribute("x", $elem->getAttribute("x") + (double) $_POST['x1']);
     $elem->setAttribute("y", $elem->getAttribute("y") + (double) $_POST['y1']);
开发者ID:pawelzielak,项目名称:opencaching-pl,代码行数:31,代码来源:remotelogbook.php

示例10: DomDocument

<?php

$xdoc = new DomDocument();
$xmlfile = '../examples/service.xml';
$xmlschema = './xrdl.xsd';
//Load the xml document in the DOMDocument object
$xdoc->Load($xmlfile);
//Validate the XML file against the schema
if ($xdoc->schemaValidate($xmlschema)) {
    print "{$xmlfile} is valid.\n";
} else {
    print "{$xmlfile} is invalid.\n";
}
开发者ID:joe2night,项目名称:xrdl,代码行数:13,代码来源:validator.php


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