本文整理汇总了PHP中DOMDocument::loadxml方法的典型用法代码示例。如果您正苦于以下问题:PHP DOMDocument::loadxml方法的具体用法?PHP DOMDocument::loadxml怎么用?PHP DOMDocument::loadxml使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DOMDocument
的用法示例。
在下文中一共展示了DOMDocument::loadxml方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Parse
function Parse()
{
$dom = new DOMDocument();
$dom->loadxml($this->xml);
$toplevel = $dom->getElementsByTagName('toplevel');
$suggestions = $dom->getElementsByTagName('suggestion');
foreach ($suggestions as $suggestion) {
$this->data[] = $suggestion->getAttribute('data');
}
$this->link = 'https://www.google.com/#safe=off&q=' . $this->query . '&lr=lang_' . $this->locale;
$this->Cache();
}
示例2: Suggest
/**
*
*/
public function Suggest($thisxml)
{
$DOMDo = new DOMDocument();
$DOMDo->loadxml($thisxml);
$toplevel = $DOMDo->getElementsByTagName('toplevel');
$Suggest = $DOMDo->getElementsByTagName('suggestion');
$Data = array();
foreach ($Suggest as $Suggests) {
$Data[] = $Suggests->getAttribute('data');
}
return $Data;
}
示例3: anno_validate
/**
* @package anno
* This file is part of the Annotum theme for WordPress
* Built on the Carrington theme framework <http://carringtontheme.com>
*
* Copyright 2008-2014 Crowd Favorite, Ltd. All rights reserved. <http://crowdfavorite.com>
* Released under the GPL license
* http://www.opensource.org/licenses/gpl-license.php
*/
function anno_validate($content, $schema)
{
$response = array();
$response['status'] = '';
$doc = new DOMDocument();
libxml_use_internal_errors(true);
libxml_clear_errors();
$doc->loadxml($content);
if (!$doc->relaxNGValidate($schema)) {
$response['status'] = 'error';
$errors = libxml_get_errors();
if (is_array($errors)) {
foreach ($errors as $libxml_error) {
$response['errors'][] = array('fullMessage' => sprintf(__('Error on line %d, column %d. %s', 'Error message for validation. %s referes to the error message', 'anno'), $libxml_error->line, $libxml_error->column, str_replace('\\n', '', $libxml_error->message)), 'line' => $libxml_error->line - 1, 'column' => $libxml_error->column, 'message' => str_replace('\\n', '', $libxml_error->message), 'level' => $libxml_error->level);
}
}
} else {
$response['status'] = 'success';
}
return $response;
}
示例4: process
/**
* Try to process the XSLT transformation
*
* @param string XML to process.
* @param string XSLT sheet to use for the processing.
*
* @throws BuildException On XSLT errors
*/
protected function process($xml, $xsl)
{
$processor = new XSLTProcessor();
// Create and setup document.
$xmlDom = new DOMDocument();
$xmlDom->resolveExternals = $this->resolveDocumentExternals;
// Create and setup stylesheet.
$xslDom = new DOMDocument();
$xslDom->resolveExternals = $this->resolveStylesheetExternals;
if ($this->html) {
$xmlDom->loadHTML($xml);
} else {
$xmlDom->loadXML($xml);
}
$xslDom->loadxml($xsl);
$processor->importStylesheet($xslDom);
// ignoring param "type" attrib, because
// we're only supporting direct XSL params right now
foreach ($this->xsltParams as $param) {
$this->log("Setting XSLT param: " . $param->getName() . "=>" . $param->getExpression(), Project::MSG_DEBUG);
$processor->setParameter(null, $param->getName(), $param->getExpression());
}
$errorlevel = error_reporting();
error_reporting($errorlevel & ~E_WARNING);
@($result = $processor->transformToXML($xmlDom));
error_reporting($errorlevel);
if (false === $result) {
//$errno = xslt_errno($processor);
//$err = xslt_error($processor);
throw new BuildException("XSLT Error");
} else {
return $result;
}
}
示例5: process
/**
* Try to process the XSLT transformation
*
* @param string XML to process.
* @param string XSLT sheet to use for the processing.
*
* @throws BuildException On XSLT errors
*/
protected function process($xml, $xsl)
{
$processor = new XSLTProcessor();
// Create and setup document.
$xmlDom = new DOMDocument();
$xmlDom->resolveExternals = $this->resolveDocumentExternals;
// Create and setup stylesheet.
$xslDom = new DOMDocument();
$xslDom->resolveExternals = $this->resolveStylesheetExternals;
if ($this->html) {
$xmlDom->loadHTML($xml);
} else {
$xmlDom->loadXML($xml);
}
$xslDom->loadxml($xsl);
if (defined('XSL_SECPREF_WRITE_FILE')) {
if (version_compare(PHP_VERSION, '5.4', "<")) {
ini_set("xsl.security_prefs", XSL_SECPREF_WRITE_FILE | XSL_SECPREF_CREATE_DIRECTORY);
} else {
$proc->setSecurityPrefs(XSL_SECPREF_WRITE_FILE | XSL_SECPREF_CREATE_DIRECTORY);
}
}
$processor->importStylesheet($xslDom);
// ignoring param "type" attrib, because
// we're only supporting direct XSL params right now
foreach ($this->xsltParams as $param) {
$this->log("Setting XSLT param: " . $param->getName() . "=>" . $param->getExpression(), Project::MSG_DEBUG);
$processor->setParameter(null, $param->getName(), $param->getExpression());
}
$errorlevel = error_reporting();
error_reporting($errorlevel & ~E_WARNING);
@($result = $processor->transformToXML($xmlDom));
error_reporting($errorlevel);
if (false === $result) {
//$errno = xslt_errno($processor);
//$err = xslt_error($processor);
throw new BuildException("XSLT Error");
} else {
return $result;
}
}
示例6: showfilelist
function showfilelist()
{
global $verstr;
?>
<form action="?action=showfile" method="post" name="updateform">
<table class="tb" >
<tr>
<td width="4%"> </td>
<td width="15%">升级文件</td>
<td width="15%">更新时间</td>
<td width="40%">描述信息</td>
<td width="10%">更新状态</td>
</tr>
<?php
if (getcheckversion()) {
$doc = new DOMDocument();
$doc->formatOutput = true;
$doc->loadxml($verstr);
$xmlnode = $doc->documentElement;
$nodes = $xmlnode->getElementsByTagName("file");
foreach ($nodes as $node) {
$filedes = $node->attributes->item(0)->nodeValue;
$filetime = $node->attributes->item(1)->nodeValue;
$filesrc = $node->attributes->item(2)->nodeValue;
?>
<tr>
<td><input type="checkbox" value="<?php
echo $filesrc;
?>
||||<?php
echo $filetime;
?>
" name="f_id[]" id="f_id"/></td>
<td><?php
echo replaceStr($filesrc, version, "");
?>
</td>
<td><?php
echo $filetime;
?>
</td>
<td><?php
echo $filedes;
?>
</td>
<td><?php
echo getFileIsUpdate($filesrc, $filetime);
?>
</td>
</tr>
<?php
}
?>
<tr><td colspan="5"><label>全选<input type="checkbox" name="chkall" id="chkall" class="checkbox" onClick="checkAll(this.checked,'f_id[]')" /></label>
<input class="inputbut" type="submit" value="批量升级" name="Submit">升级前最好备份数据,以免升级失败造成不必要的麻烦!</td></tr>
<?php
} else {
echo "<tr><td colspan=\"5\" >已经是最新版本,无需升级,请随时关注 www.joyplus.com 官方信息!</td></tr>";
}
unset($nodes);
unset($xmlnode);
unset($doc);
?>
</table></form></body></html>
<?php
}
示例7: update_profile_status
function update_profile_status()
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_COOKIEJAR, $GLOBALS['cookies']);
curl_setopt($ch, CURLOPT_COOKIEFILE, $GLOBALS['cookies']);
curl_setopt($ch, CURLOPT_USERAGENT, $GLOBALS['uagent']);
curl_setopt($ch, CURLOPT_URL, 'https://m.google.com/app/plus/?v=compose&group=m1c&hideloc=1');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
$buf = utf8_decode(html_entity_decode(str_replace('&', '', curl_exec($ch))));
$header = curl_getinfo($ch);
curl_close($ch);
if ($GLOBALS['debug']) {
echo $buf;
}
$params = '';
$doc = new DOMDocument();
$doc->loadxml($buf);
$inputs = $doc->getElementsByTagName('input');
foreach ($inputs as $input) {
if ($input->getAttribute('name') != 'editcircles') {
$params .= $input->getAttribute('name') . '=' . urlencode($input->getAttribute('value')) . '&';
}
}
$params .= 'newcontent=' . urlencode($GLOBALS['status']);
//$baseurl = $doc->getElementsByTagName('base')->item(0)->getAttribute('href');
$baseurl = 'https://m.google.com' . parse_url($header['url'], PHP_URL_PATH);
$ch = curl_init();
curl_setopt($ch, CURLOPT_COOKIEJAR, $GLOBALS['cookies']);
curl_setopt($ch, CURLOPT_COOKIEFILE, $GLOBALS['cookies']);
curl_setopt($ch, CURLOPT_USERAGENT, $GLOBALS['uagent']);
curl_setopt($ch, CURLOPT_URL, $baseurl . '?v=compose&group=m1c&hideloc=1&a=post');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_REFERER, $baseurl . '?v=compose&group=m1c&hideloc=1');
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
$buf = curl_exec($ch);
$header = curl_getinfo($ch);
curl_close($ch);
if ($GLOBALS['debug']) {
echo $buf;
}
echo "\n[+] POST Updating status on: " . $baseurl . "\n\n";
}
示例8: process
/**
* Try to process the XSLT transformation
*
* @param string XML to process.
* @param string XSLT sheet to use for the processing.
*
* @throws BuildException On XSLT errors
*/
protected function process($xml, $xsl)
{
$processor = new XSLTProcessor();
$xmlDom = new DOMDocument();
$xslDom = new DOMDocument();
if ($this->html) {
$xmlDom->loadHTML($xml);
} else {
$xmlDom->loadXML($xml);
}
$xslDom->loadxml($xsl);
$processor->importStylesheet($xslDom);
// ignoring param "type" attrib, because
// we're only supporting direct XSL params right now
foreach ($this->xsltParams as $param) {
$this->log("Setting XSLT param: " . $param->getName() . "=>" . $param->getExpression(), PROJECT_MSG_DEBUG);
$processor->setParameter(null, $param->getName(), $param->getExpression());
}
$result = $processor->transformToXML($xmlDom);
if (!$result) {
//$errno = xslt_errno($processor);
//$err = xslt_error($processor);
throw new BuildException("XSLT Error");
} else {
return $result;
}
}
示例9: DOMDocument
$orderline = "";
foreach ($cart as $key => $name) {
$orderline .= '<orderline productid = "' . $name['ezproduct_sku'] . '">
<quantity>' . $name['number'] . '</quantity>
</orderline>';
}
$doc = new DOMDocument();
$doc->loadxml('<orders partnerid = "717" version = "1">
<ordersession>
<order>
<shippingaddress>
<title>Ms</title>
<firstname>' . $firstname . '</firstname>
<lastname>' . $lastname . '</lastname>
<address1>' . $address1 . '</address1>
<address2>' . $address2 . '</address2>
<city>' . $city . '</city>
<state>' . $state . '</state>
<zip>' . $zip . '</zip>
<countrycode>' . $countrycode . '</countrycode>
</shippingaddress>
' . $orderline . '</order>
</ordersession>
</orders>');
$ezPrintsXML = $doc->saveXML();
// Generate an XML stringto send to EZPrints. $doc is a DOMDocument populated with required EZPrints data. Alternatively the $ezPrintsXML string can be generated manually.
// create a header array that specifies a blank content type.
$header[] = "Content-type:";
// initialize CURL to use the EZPrints URL
$ch = curl_init("http://www.ezprints.com/ezpartners/shippingcalculator/xmlshipcalc.asp");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
示例10: logout
function logout()
{
$dom = new DOMDocument();
@$dom->loadxml(grab_home());
$links = $dom->getElementsByTagName('a');
foreach ($links as $link) {
if (strpos($link->getAttribute('href'), 'logout.php')) {
$logout = $link->getAttribute('href');
break;
}
}
$url = 'https://m.facebook.com' . $logout;
/*
* just logout lol
*/
$ch = curl_init();
curl_setopt($ch, CURLOPT_COOKIEJAR, $GLOBALS['cookies']);
curl_setopt($ch, CURLOPT_COOKIEFILE, $GLOBALS['cookies']);
curl_setopt($ch, CURLOPT_USERAGENT, $GLOBALS['uagent']);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
$loggedout = curl_exec($ch);
if ($GLOBALS['debug']) {
echo "\nLogout url = {$url}\n";
echo $loggedout;
}
curl_close($ch);
echo "\n[i] Logged out.\n";
}
示例11: foreach
foreach ($cart as $key => $name) {
$orderline .= '<orderline ProjectId="' . $key . '"><quantity>' . $name['number'] . '</quantity></orderline>';
}
$doc = new DOMDocument();
$doc->loadxml('<orders partnerid="717" version="1">
<ordersession>
<sessionid>' . $ezopro_id . '</sessionid>
<order>
<orderid>' . $ezopro_id . '</orderid>
<shippingaddress>
<title>Ms</title>
<firstname>' . $ship_fname . '</firstname>
<lastname>' . $ship_lname . '</lastname>
<address1>' . $ship_address1 . '</address1>
<address2>' . $ship_address2 . '</address2>
<city>' . $ship_city . '</city>
<state>' . $ship_state . '</state>
<zip>' . $ship_zipcode . '</zip>
<countrycode>' . $ship_country . '</countrycode>
<phone>' . $phone . '</phone>
<email>' . $email . '</email>
</shippingaddress>
<shippingmethod>' . $ship_method . '</shippingmethod>
' . $orderline . '
</order>
</ordersession>
</orders>');
$ezPrintsXML = $doc->saveXML();
// Generate an XML stringto send to EZPrints. $doc is a DOMDocument populated with required EZPrints data. Alternatively the $ezPrintsXML string can be generated manually.
// create a header array that specifies a blank content type.
$header[] = "Content-type:";
示例12: loadTemplate
function loadTemplate($template)
{
if (isset($this->templates[$template])) {
return $this->templates[$template];
}
$data = file_get_contents($template);
$xml = new DOMDocument();
$xml->loadxml($data);
$fields = $xml->getElementsByTagName('field');
$output = array();
foreach ($fields as $field) {
$name = $field->attributes->getNamedItem('name')->nodeValue;
$type = $field->attributes->getNamedItem('type')->nodeValue;
$checked = '';
$default = '';
$label = '';
$explanation = '';
$error = '';
$transform = '';
$rules = array();
$children = $field->childNodes;
foreach ($children as $child) {
$nname = $child->nodeName;
switch ($nname) {
case 'checked':
case 'default':
case 'label':
case 'error':
case 'explanation':
case 'transform':
${$nname} = $child->nodeValue;
break;
case 'rule':
$rule_param = $child->nodeValue;
$rule_type = $child->attributes->getNamedItem('type')->nodeValue;
switch ($rule_type) {
case 'enum':
case 'symbols':
if (!isset($rules[$rule_type])) {
$rules[$rule_type] = array();
}
$rules[$rule_type][] = $rule_param;
break;
default:
$rules[$rule_type] = $rule_param;
}
break;
}
}
$setname = $name;
$newfield = new fieldtemplate($type, $setname, $label, $explanation);
if (!empty($error)) {
$newfield->setError($error);
}
if (!empty($transform)) {
$newfield->setTransform($transform);
}
if (!empty($default)) {
$newfield->default = $default;
}
if (!empty($checked)) {
$newfield->checked = $checked;
}
foreach ($rules as $key => $rule) {
$newfield->setRule($key, $rule);
}
if (empty($name)) {
$output[] = $newfield;
} else {
$output[$name] = $newfield;
}
}
return $output;
}