本文整理汇总了PHP中domxml_open_file函数的典型用法代码示例。如果您正苦于以下问题:PHP domxml_open_file函数的具体用法?PHP domxml_open_file怎么用?PHP domxml_open_file使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了domxml_open_file函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: printxmlRequest
function printxmlRequest($logname)
{
global $HTTP_RAW_POST_DATA, $xmlDoc, $xmlResponse, $xmlMessage, $result, $con;
$fp = fopen("./Log/" . $logname . "Request.xml", "w+");
fwrite($fp, $HTTP_RAW_POST_DATA);
fclose($fp);
$xmlDoc = domxml_open_file("./Log/" . $logname . "Request.xml");
}
示例2: parseXMLStr
function parseXMLStr()
{
global $HTTP_RAW_POST_DATA, $xmlResponse, $xmlMessage, $result, $con;
if (dbConnect() == FALSE) {
$xmlMessage .= "<status>Fail</status>";
$xmlMessage .= "<info>Could not connect to the database</info>";
return FALSE;
}
$fp = fopen("./Log/codes.xml", "w+");
fwrite($fp, $HTTP_RAW_POST_DATA);
fclose($fp);
$xmldoc = domxml_open_file("./Log/codes.xml");
$noderoot = $xmldoc->document_element();
if ($noderoot->tagname = "insert") {
$childnodes = $noderoot->child_nodes();
foreach ($childnodes as $value) {
if ($value->tagname == "area") {
$area = $value->get_content();
} else {
if ($value->tagname == "assoc_code") {
$assoc_code = $value->get_content();
} else {
if ($value->tagname == "paper_code") {
$paper_code = $value->get_content();
} else {
if ($value->tagname == "assoc_desc") {
$assoc_desc = $value->get_content();
} else {
if ($value->tagname == "paper_desc") {
$paper_desc = $value->get_content();
} else {
if ($value->tagname == "location") {
$location = $value->get_content();
}
}
}
}
}
}
}
if (dbOperations($area, $assoc_code, $paper_code, $assoc_desc, $paper_desc, $location) == FALSE) {
$xmlMessage .= "<status>Fail</status>";
$xmlMessage .= "<info>Registration failed, try registering again</info>";
$result = FALSE;
}
} else {
$xmlMessage .= "<status>Fail</status>";
$xmlMessage .= "<info>Wrong XMLRequest Format</info>";
$result = FALSE;
}
dbClose();
return $result;
}
示例3: unmarshal
/**
* Unmarshall a XML diagram file into an object structure (DiaDiagram)
*
* @param string filename The diagram filename (.dia)
* @return org.dia.DiaDiagram
*/
public static function unmarshal($diagram)
{
// suck in XML document
if (!($dom = domxml_open_file($diagram, DOMXML_LOAD_PARSING, $error))) {
throw new XMLFormatException(xp::stringOf($error));
}
// initialize XPath
$XPath = new XPath($dom);
// TODO: if the URI is wrong, unmarshalling won't work!
$XPath->registerNamespace('dia', 'http://www.lysator.liu.se/~alla/dia/');
// new (unused): $XPath->registerNamespace('dia', 'http://www.gnome.org/projects/dia/');
// go
$Dia = DiaUnmarshaller::recurse($XPath, $dom->document_element(), 'org.dia.DiaDiagram');
Console::writeLine('DiaUnmarshaller used up ' . round(memory_get_usage() / 1024, 2) . ' Kb of memory.');
return $Dia;
}
示例4: run
function run($srcfile)
{
$dom = domxml_open_file($srcfile);
$rawdata = $dom->dump_mem(true);
$rawdata = str_replace("<?xml version=\"1.0\" encoding=\"UTF-8\"?>", "", $rawdata);
/*
$this->addSeperator("Rawdata");
echo "<br>".$rawdata."<br>";
*/
$this->addSeperator("Content");
$rawdata = "[dojocontent]" . $rawdata . "[/dojocontent]";
$this->dl_dojoLoader->addcontenttags = false;
$content = $this->dl_dojoLoader->addContent($rawdata);
echo $content;
$this->addSeperator("Ende");
}
示例5: load
function load($in_CSSML, $in_type = 'string')
{
if (parent::isError($load = parent::load())) {
return $load;
}
// If the CSSML data is already a DOM object (can tell by checking for root)
if ($in_type == 'object' && get_class($in_CSSML) == 'DomDocument') {
$this->CSSMLDoc = $in_CSSML;
} elseif ($in_type == 'file' && @file_exists($in_CSSML)) {
$this->CSSMLDoc = domxml_open_file($in_CSSML);
} elseif ($in_type == 'string' && is_string($in_CSSML)) {
$this->CSSMLDoc = domxml_open_mem($in_CSSML);
} else {
return PEAR::raiseError(null, XML_CSSML_INVALID_DATA, null, E_USER_WARNING, "Request data: {$in_CSSML}", 'XML_CSSML_Error', true);
}
if (get_class($this->CSSMLDoc) != 'DomDocument') {
return PEAR::raiseError(null, XML_CSSML_INVALID_DOCUMENT, null, E_USER_WARNING, "Request data: {$in_CSSML}", 'XML_CSSML_Error', true);
}
$this->loaded = true;
}
示例6: unpackXML
/**
* unpackXML::unpackXML() - constructor
*
* @param $file (absolute path to file from htdocs root)
* @return
*/
function unpackXML($file)
{
if (!($this->xml = domxml_open_file($file))) {
$this->error = true;
return array('error' => 'File ' . $file . ' not found at specified location. DOMXML needs an absolute path to this file starting from htdocs root or a URI!');
} else {
//get encoding - doesn't
$myfile = fopen($file, "r");
$contents = fread($myfile, 64);
fclose($myfile);
eregi("encoding=\"(.*)\"\\?>", $contents, $encoding);
if (!empty($encoding[1]) and $encoding[1] != 'iso-8859-1') {
$this->encoding = $encoding[1];
} else {
$this->encoding = "UTF-8";
}
//set root
$this->root = $this->xml->root();
}
}
示例7: structure_reader
function structure_reader($structure_file)
{
$dom = domxml_open_file($structure_file);
if (!$dom) {
$this->error = "STRUCTURE ERROR";
return false;
}
$this->document = $dom->first_child();
$element = $this->document->first_child();
$i = 0;
while ($element) {
if ($element->node_name() == "page") {
$this->pages[$i] = new page($element->get_attribute("name"));
if ($element->get_attribute("title")) {
$this->pages[$i]->set_title($element->get_attribute("title"));
}
$i++;
}
$element = $element->next_sibling();
}
}
示例8: SMB_ReadCfg
function SMB_ReadCfg($cfg) {
if ( file_exists($cfg) ) {
$dom = domxml_open_file($cfg);
$node = $dom->get_elements_by_tagname("Server");
$smb["Server"] = $node[0]->get_content();
$node = $dom->get_elements_by_tagname("Share");
$smb["Share"] = $node[0]->get_content();
$node = $dom->get_elements_by_tagname("Domain");
$smb["Domain"] = $node[0]->get_content();
$node = $dom->get_elements_by_tagname("User");
$smb["User"] = $node[0]->get_content();
$node = $dom->get_elements_by_tagname("Password");
$smb["Password"] = $node[0]->get_content();
} else {
$smb["Server"] = "";
$smb["Share"] = "";
$smb["Domain"] = "";
$smb["User"] = "";
$smb["Password"] = "";
}
return $smb;
}
示例9: readTMXml
/**
* readTMXml
*
* @param mixed $questionCount question count
* @param mixed $scoreFilePathAndName score file with path
*
* @access public
* @return void
*/
function readTMXml($questionCount, $scoreFilePathAndName)
{
// Make sure the specified file exists
if (!file_exists($scoreFilePathAndName) || filesize($scoreFilePathAndName) <= 0) {
return false;
}
$lineSkip = $questionCount + 3;
$row_skip = 2;
$i = 0;
$score = array();
$scores = '';
if (phpversion() < 5) {
//$lineSkip--;
$dom = domxml_open_file($scoreFilePathAndName);
$scores = $dom->get_elements_by_tagname('td');
foreach ($scores as $score_tmp) {
foreach ($score_tmp->child_nodes() as $item) {
if ($i > $lineSkip) {
if (($i - 2) % ($questionCount + 2) == 0) {
$score[$i - $lineSkip - 1]['team_name'] = $item->node_value();
} elseif (($i - 2) % ($questionCount + 2) <= $questionCount) {
$score[$i - $lineSkip - ($i - 2) % ($questionCount + 2) - 1]['q_' . ($i - 1) % $questionCount] = $item->node_value();
} else {
$score[$i - $lineSkip - ($questionCount + 2)]['percent'] = $item->node_value();
}
}
}
$i++;
}
} else {
$dom = new DOMDocument();
$dom->load($scoreFilePathAndName);
$rows = $dom->getElementsByTagName('tr');
foreach ($rows as $i => $row) {
if ($i < $row_skip) {
continue;
}
foreach ($row->childNodes as $j => $item) {
if ($j == 0) {
$score[$i - $row_skip]['team_name'] = $item->nodeValue;
} elseif ($j == $questionCount + 1) {
$score[$i - $row_skip]['percent'] = $item->nodeValue;
} else {
$score[$i - $row_skip]['q_' . ($j - 1)] = $item->nodeValue;
}
}
}
/*$scores = $dom->getElementsByTagName('td');
foreach ($scores as $score_tmp) {
foreach ($score_tmp->childNodes as $item) {
if ($i > $lineSkip) {
if (($i-2)%($questionCount+2)==0) {
$score[$i-$lineSkip-1]['team_name'] = $item->nodeValue;
} elseif (($i-2)%($questionCount+2) <= $questionCount) {
$score[($i-$lineSkip-(($i-2)%($questionCount+2)))-1]['q_'.(($i-1)%($questionCount))] = $item->nodeValue;
} else {
$score[$i-$lineSkip-($questionCount+2)]['percent'] = $item->nodeValue;
}
}
}
$i++;
}*/
}
$score_tmp = array();
foreach ($score as $temp) {
array_push($score_tmp, $temp);
}
$score = $score_tmp;
return $score;
}
示例10: insert
function insert($id)
{
$XML_FILE = $_SESSION['XML_FILE'];
$rule = unserialize($_SESSION['rule']);
$directive = unserialize($_SESSION['directive']);
$tab_rules = $directive->rules;
unset($_SESSION['rule']);
list($id_dir, $id_rule, $id_father) = explode("-", $id);
init_file($XML_FILE);
if (!($dom = domxml_open_file($XML_FILE, DOMXML_LOAD_SUBSTITUTE_ENTITIES))) {
echo "Error while parsing the document\n";
exit;
}
$directive = getDirectiveFromXML($dom, $id_dir);
if ($id_father != 0) {
$tab_rules[$id_father]->nb_child = $tab_rules[$id_father]->nb_child + 1;
}
if ($id == $tab_rules[$id_rule]->id || $id_rule > count($tab_rules)) {
$tab_rules[$id_rule] = $rule;
} else {
for ($i = count($tab_rules); $i >= $id_rule; $i--) {
list($id_dir, $id_rule2, $id_father2) = explode("-", $tab_rules[$i]->id);
$new_id_rule = $i + 1;
if ($id_father2 >= $id_rule) {
$new_id_father = $id_father2 + 1;
} else {
$new_id_father = $idfather2;
}
$newid = $id_dir . "-" . $new_id_rule . "-" . $new_id_father;
$tab_rules[$i]->id = $newid;
$tab_rules[$i + 1] = $tab_rules[$i];
}
$tab_rules[$id_rule] = $rule;
}
$direct = $directive->directive;
$rules = $direct->child_nodes();
foreach ($rules as $rule) {
$direct->remove_child($rule);
}
do_directive($directive, &$tab_rules, $dom);
$dom->dump_file($XML_FILE);
release_file($XML_FILE);
$newlevel = $tab_rules[$id_rule]->level;
echo "<html><body onload=\"window.open('../viewer/index.php?directive=" . $directive->id . "&level={$newlevel}','right')\"></body></html>";
}
示例11: is_free
function is_free($directive_id, $XML_FILE = "")
{
if ($XML_FILE == "") {
$XML_FILE = get_directive_file($directive_id);
}
//if (!file_exists($XML_FILE)) return "false";
init_file($XML_FILE);
$dom = domxml_open_file($XML_FILE, DOMXML_LOAD_SUBSTITUTE_ENTITIES);
$count = 1;
$free = "true";
foreach ($dom->get_elements_by_tagname('directive') as $directive) {
$id = $directive->get_attribute('id');
$name = $directive->get_attribute('name');
$count++;
if (strcmp($id, $directive_id) == 0) {
$free = "false";
}
}
release_file($XML_FILE);
return $free;
}
示例12: getElevation
function getElevation($lat, $lng, $source)
{
$msg = "";
switch ($source) {
case "gmaps":
$url = "http://maps.google.com/maps/api/elevation/xml?locations=" . $lat . "," . $lng . "&sensor=false";
if (!($dom = @domxml_open_file($url))) {
die("Error opening xml file");
}
$xpath = @xpath_new_context($dom);
if ($_lat = @xpath_eval_expression($xpath, '//location/lat/text()')) {
$_lat = $_lat->nodeset[0]->node_value();
}
if ($_lng = @xpath_eval_expression($xpath, '//location/lng/text()')) {
$_lng = $_lng->nodeset[0]->node_value();
}
if ($alt = @xpath_eval_expression($xpath, '//elevation/text()')) {
$alt = $alt->nodeset[0]->node_value();
$msg = "";
} else {
if ($msg = @xpath_eval_expression($xpath, '//status/text()')) {
$msg = $msg->nodeset[0]->node_value();
}
}
$ds = '';
break;
case "usgs":
$url = "http://gisdata.usgs.gov/xmlwebservices2/elevation_service.asmx/getElevation?X_Value=" . $lng . "&Y_Value=" . $lat . "&Elevation_Units=METERS&Source_Layer=-1&Elevation_Only=-1";
//$dom = @domxml_open_file($url);
if (!($dom = @domxml_open_file($url))) {
die("Error opening xml file");
}
$xpath = @xpath_new_context($dom);
if ($_lat = @xpath_eval_expression($xpath, '//Y_Value/text()')) {
$_lat = $_lat->nodeset[0]->node_value();
}
if ($_lng = @xpath_eval_expression($xpath, '//X_Value/text()')) {
$_lng = $_lng->nodeset[0]->node_value();
}
//if ($alt = @xpath_eval_expression($xpath, '//Elevation/text()')) {
if ($alt = @xpath_eval_expression($xpath, '//Elevation_Only/text()')) {
$alt = $alt->nodeset[0]->node_value();
$msg = "";
} else {
if ($msg = @xpath_eval_expression($xpath, '//Elevation_Query/text()')) {
$msg = $msg->nodeset[0]->node_value();
}
}
//if ($ds = @xpath_eval($xpath, '//Data_Source/text()')) {
if ($ds = @xpath_eval_expression($xpath, '//Source_Layer/text()')) {
$ds = $ds->nodeset[0]->node_value();
}
break;
case "geonames":
$url = "http://ws.geonames.org/srtm3?lat=" . $lat . "&lng=" . $lng . "&style=full&type=XML";
//$dom = @domxml_open_file($url);
if (!($dom = @domxml_open_file($url))) {
die("Error opening xml file");
}
$xpath = @xpath_new_context($dom);
if ($_lat = @xpath_eval_expression($xpath, '//lat/text()')) {
$_lat = $_lat->nodeset[0]->node_value();
}
if ($_lng = @xpath_eval_expression($xpath, '//lng/text()')) {
$_lng = $_lng->nodeset[0]->node_value();
}
if ($alt = @xpath_eval_expression($xpath, '//srtm3/text()')) {
$alt = $alt->nodeset[0]->node_value();
$alt = $alt == '-32768' ? 0 : $alt;
$msg = "";
}
/* else {
if ($msg = @xpath_eval_expression($xpath, '//Elevation_Query/text()')) {
$msg = $msg->nodeset[0]->node_value();
}
}*/
$ds = 'SRTM3';
break;
default:
exit;
}
return array("lat" => $_lat, "lng" => $_lng, "alt" => $alt, "src" => $ds, "msg" => $msg, "url" => $url);
}
示例13: Load
function Load($filename)
{
$filepath = realpath($filename);
if (EWRPT_IS_PHP5) {
return $this->XmlDoc->load($filepath);
} else {
if (function_exists("domxml_open_file")) {
$this->XmlDoc = domxml_open_file($filepath);
}
return $this->XmlDoc;
}
}
示例14: disp
{
$this->test_var4 = $value;
echo "test_var4 property set to {$value}<br />\n";
return true;
}
function disp()
{
echo "<pre>";
var_dump($this);
echo "</pre>";
}
}
$obj = new test_class(1, 'arg2');
$obj->set_var1('test1');
$obj->set_var2(123);
$obj->set_var3($a);
/* Array from previous test */
$obj->set_var4(array(1, 2, 3, 4, 5, 6, 7, 8, 9));
$obj->disp();
?>
<h2>And finally a bit of XML and XSLT</h2>
<?php
$xml = domxml_open_file('presentations/slides/intro/menu.xml');
$xsl = domxml_xslt_stylesheet_file('presentations/slides/intro/menu.xsl');
$out = $xsl->process($xml);
echo $out->dump_mem();
?>
</p>
</body>
</html>
示例15: yahoo_geocode
function yahoo_geocode($location)
{
if (!preg_match('/\\[(.+),[ ]?(.+)\\]/', $location, $matches)) {
$client = new Snoopy();
$client->agent = GEOPRESS_USER_AGENT;
$client->read_timeout = GEOPRESS_FETCH_TIMEOUT;
$client->use_gzip = GEOPRESS_USE_GZIP;
$url = yahoo_geocoder . urlencode($location);
@$client->fetch($url);
$xml = $client->results;
$dom = domxml_open_file($xml);
$lat = "";
$lon = "";
// $lat = $dom->get_elements_by_tagname('Latitude')[0].child_nodes()[0]->node_value();
// $lon = $dom->get_elements_by_tagname('Longitude')[0].child_nodes()[0]->node_value();
// $latlong = "";
// if (preg_match("/<Latitude>(.*)<\/Latitude>.*<Longitude>(.*)<\/Longitude>/", $xml, $latlong)) {
// $lat = $latlong[1];
// $lon = $latlong[2];
// }
} else {
$lat = $matches[1];
$lon = $matches[2];
}
return array($lat, $lon);
}