本文整理汇总了PHP中DOMDocument::appendchild方法的典型用法代码示例。如果您正苦于以下问题:PHP DOMDocument::appendchild方法的具体用法?PHP DOMDocument::appendchild怎么用?PHP DOMDocument::appendchild使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DOMDocument
的用法示例。
在下文中一共展示了DOMDocument::appendchild方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: validate
function validate()
{
if (!($dom_sxe = dom_import_simplexml($this->_xml))) {
return false;
}
$dom = new DOMDocument("1.0");
$dom_sxe = $dom->importnode($dom_sxe, true);
$dom_sxe = $dom->appendchild($dom_sxe);
return $dom->relaxNGValidate();
}
示例2: toQueueXML
public function toQueueXML()
{
$dom = new \DOMDocument("1.0", "utf-8");
$dom->formatOutput = TRUE;
$root = $dom->createElement("Queue");
//创建根节点
$dom->appendchild($root);
$price = $dom->createAttribute("xmlns");
$root->appendChild($price);
$priceValue = $dom->createTextNode('http://mqs.aliyuncs.com/doc/v1/');
$price->appendChild($priceValue);
foreach ($this->attributes as $k => $v) {
$queue = $dom->createElement($k);
$root->appendChild($queue);
$titleText = $dom->createTextNode($v);
$queue->appendChild($titleText);
}
return $dom->saveXML();
}
示例3: generatexml
private function generatexml($msgbody, $DelaySeconds = 0, $Priority = 8)
{
header('Content-Type: text/xml;');
$dom = new DOMDocument("1.0", "utf-8");
$dom->formatOutput = TRUE;
$root = $dom->createElement("Message");
//创建根节点
$dom->appendchild($root);
$price = $dom->createAttribute("xmlns");
$root->appendChild($price);
$priceValue = $dom->createTextNode('http://mqs.aliyuncs.com/doc/v1/');
$price->appendChild($priceValue);
$msg = array('MessageBody' => $msgbody, 'DelaySeconds' => $DelaySeconds, 'Priority' => $Priority);
foreach ($msg as $k => $v) {
$msg = $dom->createElement($k);
$root->appendChild($msg);
$titleText = $dom->createTextNode($v);
$msg->appendChild($titleText);
}
return $dom->saveXML();
}
示例4: searchRetrieveRequest
public function searchRetrieveRequest($params)
{
$finna = new Finna();
if (!isset($params['maximumRecords'])) {
$limit = 0;
} else {
$limit = $params['maximumRecords'];
}
if (!empty($params['x-pquery'])) {
$params['query'] = $params['x-pquery'];
}
$apiParams = array('limit' => $limit);
if (!empty($params['startRecord'])) {
$apiParams['page'] = $params['startRecord'];
}
$finnaResults = $finna->search($params['query'], $apiParams);
$dom = new DOMDocument('1.0', 'UTF-8');
$xmlRoot = $dom->createElementNS('http://docs.oasis-open.org/ns/search-ws/sruResponse', 'zs:searchRetrieveResponse');
$xmlRoot = $dom->appendchild($xmlRoot);
$numberOfRecords = $dom->createElement('zs:numberOfRecords', $finnaResults['resultCount']);
$xmlRoot->appendChild($numberOfRecords);
if (!empty($finnaResults['records'])) {
$records = $dom->createElement('zs:records');
$positionIndex = 1;
foreach ($finnaResults['records'] as $record) {
$domRecord = new DOMDocument();
$domRecord->loadXML($record['fullRecord']);
if (!$domRecord) {
Log::write('corrupted XML');
Log::write(print_r($record, 1));
break;
}
$recordList = $domRecord->getElementsByTagName('record');
if (!$recordList->length) {
Log::write('unexpected result, no records found');
Log::write(print_r($record, 1));
break;
}
$importedRecord = $dom->importNode($recordList->item(0), true);
$ourRecord = $dom->createElement('zs:record');
$recordXMLEscaping = $dom->createElement('zs:recordXMLEscaping', 'xml');
$ourRecord->appendChild($recordXMLEscaping);
$recordSchema = $dom->createElement('zs:recordSchema');
$ourRecord->appendChild($recordSchema);
$recordData = $dom->createElement('zs:recordData');
$recordData->appendChild($importedRecord);
$ourRecord->appendChild($recordData);
$recordPosition = $dom->createElement('zs:recordPosition', $positionIndex);
$ourRecord->appendChild($recordPosition);
$records->appendChild($ourRecord);
$positionIndex++;
}
$xmlRoot->appendChild($records);
}
$echoedRequest = $dom->createElement('zs:echoedSearchRetrieveRequest');
foreach ($params as $key => $value) {
$element = $dom->createElement('zs:' . $key, $value);
$echoedRequest->appendchild($element);
}
$xmlRoot->appendChild($echoedRequest);
return $dom->saveXML();
}
示例5: generatequeuexml
private function generatequeuexml($queue = array())
{
header('Content-Type: text/xml;');
$dom = new DOMDocument("1.0", "utf-8");
$dom->formatOutput = TRUE;
$root = $dom->createElement("Queue");
//创建根节点
$dom->appendchild($root);
$price = $dom->createAttribute("xmlns");
$root->appendChild($price);
$priceValue = $dom->createTextNode('http://mqs.aliyuncs.com/doc/v1/');
$price->appendChild($priceValue);
foreach ($queue as $k => $v) {
$queue = $dom->createElement($k);
$root->appendChild($queue);
$titleText = $dom->createTextNode($v);
$queue->appendChild($titleText);
}
return $dom->saveXML();
}
示例6: DOMDocument
<?php
$dom = new DOMDocument('1.0');
$books = $dom->appendchild($dom->CreateElement('books'));
$book = $books->appendchild($dom->CreateElement('book'));
$title = $book->appendchild($dom->createElement('title'));
$title->appendchild($dom->createTextNode('visual studio.net'));
$authar = $books->appendchild($dom->createelement('authar'));
$authar->appendchild($dom->createtextnode('.net'));
$dom->formatoutput = true;
$test1 = $dom->savexml();
$dom->save('exam6.xml');
示例7: header
header('last-modified: ' . date('r'));
header('pragma:no-cache');
$dom = new DOMDocument('1.0');
if (file_exists('guesebook.xml')) {
$gb = simplexml_load_file('guesebook.xml');
foreach ($gb->item as $item) {
$gbit_arry[] = (int) $item->id;
}
$gbid = max($gbit_arry) + 1;
$gb = dom_import_simplexml($gb);
$gb = $dom->importnode($gb, true);
} else {
$gb = $dom->createelement('guestbook');
$gbid = 1;
}
$gb = $dom->appendchild($gb);
$item = $dom->createelement("item");
//id
$id = $dom->createelement('id');
$text = $dom->createtextnode($gbid);
$id->appendchild($text);
$id = $item->appendchild($id);
$user = $dom->createelement('user');
$text = $dom->createtextnode(trim($_POST['user']));
$user->appendchild($text);
$user = $item->appendchild($user);
$item = $gb->appendchild($item);
echo $dom->saveXML();
$dom->save("guestbook.xml");
}
?>
示例8: trim
$clean_api_secret = trim($_POST['secret_key']);
if ($clean_api_key != "" && $clean_api_secret != "") {
$response = @file_get_contents('https://rest.nexmo.com/account/numbers/' . $clean_api_key . '/' . $clean_api_secret);
//fetching from number
$msg_from = (array) json_decode($response);
if (isset($msg_from['numbers'][0]->msisdn) && $msg_from['numbers'][0]->msisdn != "") {
//
$nexmo_key = $clean_api_key;
$secret_key = $clean_api_secret;
$from_number = $msg_from['numbers'][0]->msisdn;
$campaign_monitor = $_POST['campaign_monitor'];
$phone_number_field = $_POST['phone_number_field'];
$doc = new DOMDocument();
$doc->formatOutput = true;
$s = $doc->createElement("settings");
$doc->appendchild($s);
$r = $doc->createElement("nexmo");
$doc->appendChild($r);
$api = $doc->createElement("api");
$api->appendChild($doc->createTextNode($nexmo_key));
$r->appendChild($api);
$secretkey = $doc->createElement("secretkey");
$secretkey->appendChild($doc->createTextNode($secret_key));
$r->appendChild($secretkey);
$fromnumber = $doc->createElement("fromnumber");
$fromnumber->appendChild($doc->createTextNode($from_number));
$r->appendChild($fromnumber);
$s->appendChild($r);
$b = $doc->createElement("campaignmonitor");
$doc->appendChild($b);
$api = $doc->createElement("api");