本文整理汇总了PHP中DOMDocument::createAttribute方法的典型用法代码示例。如果您正苦于以下问题:PHP DOMDocument::createAttribute方法的具体用法?PHP DOMDocument::createAttribute怎么用?PHP DOMDocument::createAttribute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DOMDocument
的用法示例。
在下文中一共展示了DOMDocument::createAttribute方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
public function execute(InputInterface $input, OutputInterface $output)
{
$file = $input->getArgument('file');
if (!preg_match("'^/|(?:[^:\\\\/]+://)|(?:[a-z]:[\\\\/])'i", $file)) {
$file = $this->directory . '/resource/' . $file . '.html.xml';
}
$file = Filesystem::normalizePath($file);
$questionHelper = $this->getHelper('question');
$question = new ConfirmationQuestion(sprintf('Create view <info>%s</info>? [n] ', $file), false);
if (!$questionHelper->ask($input, $output, $question)) {
return;
}
$xml = new \DOMDocument('1.0', 'UTF-8');
$xml->formatOutput = true;
$root = $xml->appendChild($xml->createElementNS(ExpressViewParser::NS_EXPRESS, 'k:composition'));
$root->appendChild($xml->createAttribute('extends'));
$root->appendChild($xml->createAttribute('xmlns'))->appendChild($xml->createTextNode(ExpressViewParser::NS_XHTML));
$root->appendChild($xml->createTextNode("\n\n "));
$block = $root->appendChild($xml->createElementNS(ExpressViewParser::NS_EXPRESS, 'k:block'));
$block->appendChild($xml->createAttribute('name'))->appendChild($xml->createTextNode('main'));
$block->appendChild($xml->createTextNode("\n TODO: Create composition contents...\n "));
$root->appendChild($xml->createTextNode("\n\n"));
Filesystem::writeFile($file, $xml->saveXML());
$output->writeln('');
$output->writeln(sprintf('CREATED: <info>%s</info>', $file));
}
示例2: addCustomerToIndex
function addCustomerToIndex($customerId)
{
$indexDoc = simplexml_load_file('customer-index.xml');
$lastValue = $indexDoc->lastIndex;
$lastValue = $lastValue + 1;
$dom = new DOMDocument();
$dom->load("customer-index.xml");
$value = '2290000000' . $lastValue;
$dom->getElementsByTagName('lastIndex')->item(0)->nodeValue = $lastValue;
//update the last value
//$doc->getElementsByTagName("title")->item(0)->nodeValue = $titleText;
$customerElement = $dom->createElement('customer');
//createNode($dom, $dom->customers,'customer');
$custIdAttr = $dom->createAttribute('customer_id');
$custIdVal = $dom->createTextNode($customerId);
$custIdAttr->appendChild($custIdVal);
$customerElement->appendChild($custIdAttr);
$suIdAttr = $dom->createAttribute('cust_sid');
$suIdVal = $dom->createTextNode($value);
$suIdAttr->appendChild($suIdVal);
$customerElement->appendChild($suIdAttr);
$dom->getElementsByTagName('customers')->item(0)->appendChild($customerElement);
$dom->save('customer-index.xml');
return $value;
}
示例3: geraXML
function geraXML()
{
$this->Id = 'ID' . $this->cUF . $this->CNPJ . $this->mod . $this->serie . $this->nNFIni . $this->nNFFin;
$dom = new DOMDocument('1.0', 'utf-8');
$dom->formatOutput = false;
$DP01 = $dom->appendChild($dom->createElement('inutNFe'));
$DP01_att1 = $DP01->appendChild($dom->createAttribute('versao'));
$DP01_att1->appendChild($dom->createTextNode($this->versao));
$DP01_att2 = $DP01->appendChild($dom->createAttribute('xmlns'));
$DP01_att2->appendChild($dom->createTextNode('http://www.portalfiscal.inf.br/nfe'));
$DP03 = $DP01->appendChild($dom->createElement('infInut'));
$DP04 = $DP03->setAttribute('Id', $this->Id);
$DP05 = $DP03->appendChild($dom->createElement('tpAmb', $this->tpAmb));
$DP06 = $DP03->appendChild($dom->createElement('xServ', $this->xServ));
$DP07 = $DP03->appendChild($dom->createElement('cUF', $this->cUF));
$DP08 = $DP03->appendChild($dom->createElement('ano', $this->ano));
$DP09 = $DP03->appendChild($dom->createElement('CNPJ', $this->CNPJ));
$DP10 = $DP03->appendChild($dom->createElement('mod', $this->mod));
$DP11 = $DP03->appendChild($dom->createElement('serie', $this->serie));
$DP12 = $DP03->appendChild($dom->createElement('nNFIni', $this->nNFIni));
$DP13 = $DP03->appendChild($dom->createElement('nNFFin', $this->nNFFin));
$DP14 = $DP03->appendChild($dom->createElement('xJust', $this->xJust));
$xml = $dom->saveXML();
$assinatura = new assinatura();
$this->XML = $assinatura->assinaXML($xml, 'infInut');
return $this->XML;
}
示例4: render
public function render($caption_set, $file = false)
{
$dom = new \DOMDocument("1.0");
$dom->formatOutput = true;
$root = $dom->createElement('tt');
$dom->appendChild($root);
$body = $dom->createElement('body');
$root->appendChild($body);
$xmlns = $dom->createAttribute('xmlns');
$xmlns->appendChild($dom->createTextNode('http://www.w3.org/ns/ttml'));
$root->appendChild($xmlns);
$div = $dom->createElement('div');
$body->appendChild($div);
foreach ($caption_set->captions() as $index => $caption) {
$entry = $dom->createElement('p');
$from = $dom->createAttribute('begin');
$from->appendChild($dom->createTextNode(DfxpHelper::time_to_string($caption->start())));
$entry->appendChild($from);
$to = $dom->createAttribute('end');
$to->appendChild($dom->createTextNode(DfxpHelper::time_to_string($caption->end())));
$entry->appendChild($to);
$entry->appendChild($dom->createCDATASection($caption->text()));
$div->appendChild($entry);
}
if ($file) {
return file_put_contents($file, $dom->saveXML());
} else {
return $dom->saveHTML();
}
}
示例5: busdetail
public static function busdetail($data)
{
//print_r($data); exit;
$date = date('Y-m-d', strtotime($data['formdate']));
//header("Content-Type: text/xml");
$xmlDoc = new DOMDocument();
$root = $xmlDoc->appendChild($xmlDoc->createElement("soapenv:Envelope"));
$root->appendChild($xmlDoc->createAttribute("xmlns:soapenv"))->appendChild($xmlDoc->createTextNode("http://www.w3.org/2003/05/soap-envelope"));
$root->appendChild($xmlDoc->createAttribute("xmlns:bus"))->appendChild($xmlDoc->createTextNode("http://192.168.0.131/TT/BusBookingAPI"));
$header = $root->appendChild($xmlDoc->createElement("soapenv:Header"));
$authenticationdata = $header->appendChild($xmlDoc->createElement("bus:AuthenticationData"));
//$authenticationdata->appendChild(
//$xmlDoc->createElement("bus:SiteName",""));
//$authenticationdata->appendChild(
//$xmlDoc->createElement("bus:AccountCode",""));
$authenticationdata->appendChild($xmlDoc->createElement("bus:UserName", "appan"));
$authenticationdata->appendChild($xmlDoc->createElement("bus:Password", "appan@1234"));
$body = $root->appendChild($xmlDoc->createElement("soapenv:Body"));
$searchrequest = $body->appendChild($xmlDoc->createElement("bus:Search"));
$search = $searchrequest->appendChild($xmlDoc->createElement("bus:wsBusSearchRequest"));
$search->appendChild($xmlDoc->createElement("bus:SourceId", $data['formplace']));
$search->appendChild($xmlDoc->createElement("bus:DestinationId", $data['toplace']));
$search->appendChild($xmlDoc->createElement("bus:DateOfJourney", $date));
$search->appendChild($xmlDoc->createElement("bus:SourceName", $data['sourcename']));
$search->appendChild($xmlDoc->createElement("bus:DestinationName", $data['destinationname']));
$search->appendChild($xmlDoc->createElement("bus:IsDomestic", '1'));
$xmlDoc->formatOutput = true;
//print_r($xmlDoc);
return $xmlDoc->saveXML();
}
示例6: getSitemapDocument
/**
* generating DOMDocument object for sitemap.xml based on the links array based
* @param OutputInterface $output
* @param array $links array holds links information derived from Arachnide
* @param string $frequency
* @return \DOMDocument
*/
protected function getSitemapDocument(OutputInterface $output, array $links, $frequency)
{
$xmlDoc = new \DOMDocument("1.0", "UTF-8");
$urlset = $xmlDoc->createElement('urlset');
$xmlns = $xmlDoc->createAttribute('xmlns');
$xmlns->value = "http://www.sitemaps.org/schemas/sitemap/0.9";
$xmlns_xsi = $xmlDoc->createAttribute('xmlns:xsi');
$xmlns_xsi->value = "http://www.w3.org/2001/XMLSchema-instance";
$xsi_schemaLocation = $xmlDoc->createAttribute('xsi:schemaLocation');
$xsi_schemaLocation->value = "http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd";
$urlset->appendChild($xmlns);
$urlset->appendChild($xmlns_xsi);
$urlset->appendChild($xsi_schemaLocation);
$output->writeln('<info>Adding links to sitemap:</info>');
foreach ($links as $uri => $link) {
if (isset($link['absolute_url']) === false) {
continue;
}
if ($link['external_link'] === true) {
//never add link pointing to other site to sitemap.xml
continue;
}
$url = $xmlDoc->createElement('url');
$loc = $xmlDoc->createElement('loc', $link['absolute_url']);
$changefreq = $xmlDoc->createElement('changefreq', $frequency);
$priority = $xmlDoc->createElement('priority', '1.00');
$url->appendChild($loc);
$url->appendChild($changefreq);
$url->appendChild($priority);
$urlset->appendChild($url);
$output->writeln('<comment>' . $link['absolute_url'] . '</comment>');
}
$xmlDoc->appendChild($urlset);
return $xmlDoc;
}
示例7: render
function render()
{
$dom = new DOMDocument("1.0");
$root = $dom->createElement("gpx");
$dom->appendChild($root);
$creator = $dom->createAttribute("createor");
$version = $dom->createAttribute("version");
$version_value = $dom->createTextNode("1.0");
$version->appendChild($version_value);
$root->appendChild($creator);
$root->appendChild($version);
$trk = $dom->createElement("trk");
$root->appendChild($trk);
$trkseg = $dom->createElement("trkseg");
$trk->appendChild($trkseg);
/* Create the items */
foreach ($this->data as $point) {
$trkpt = $dom->createElement("trkpt");
foreach ($point as $key => $value) {
$attribute = $dom->createAttribute($key);
$text = $dom->createTextNode($value);
$attribute->appendChild($text);
$trkpt->appendChild($attribute);
}
$trkseg->appendChild($trkpt);
}
header("Content-type: text/xml");
return $dom->saveXML();
}
示例8: getXml
/**
* Get configs xml object.
*
* @return \DOMDocument
*/
public function getXml()
{
$dom = new DOMDocument('1.0', 'UTF-8');
$dom->xmlStandalone = false;
$dom->preserveWhiteSpace = false;
$dom->formatOutput = true;
$configs = $dom->createElement('configs');
$attr_delete = $dom->createAttribute('delete');
$attr_delete->value = $this->delete === true ? 'true' : 'false';
$configs->appendChild($attr_delete);
if (!empty($this->valid_to)) {
$attr_valid_to = $dom->createAttribute('valid_to');
$attr_valid_to->value = date('c', $this->valid_to);
$configs->appendChild($attr_valid_to);
}
foreach ($this->configs as $config) {
/* @var $config Guacamole_Config_Protocol_Abstract */
foreach ($config->getXml()->getElementsByTagName('config') as $dom_element) {
$local_dom_element = $dom->importNode($dom_element, true);
$configs->appendChild($local_dom_element);
}
}
$dom->appendChild($configs);
return $dom;
}
示例9: nodeAttributes
/**
* Map a set of node attributes to a node.
*
* @param DOMNode $node
* @param array $attributes
*/
public function nodeAttributes(&$node, $attributes)
{
foreach ($attributes as $key => $value) {
$attribute = $this->dom->createAttribute($key);
$attribute->value = $value;
$node->appendChild($attribute);
}
}
示例10: create
public function create()
{
// No user menu in client mode.
if (Filter_Client::enabled()) {
return "";
}
// Modify the menu based on user access level.
$mainmenu = $this->accesscontrol($this->mainmenu());
// To create CSS menu the HTML structure needs to be like this:
// <ul id="menu" class="menu">
// <li>
// Menu entry
// <li>Subitem</li>
// </ul>
// </li>
// <li>Another entry</li>
// </ul>
$document = new DOMDocument("1.0", "UTF-8");
$document->encoding = "UTF-8";
$document->preserveWhiteSpace = false;
$document->loadXML('<ul id="usermenu" class="menu"></ul>');
$xpath = new DOMXpath($document);
$nodes = $xpath->query("//ul");
$mainul = $nodes->item(0);
// Go through the main menu.
foreach ($mainmenu as $mainitem) {
// Build the main menu.
$mainhref = $mainitem[0];
$maintext = $mainitem[1];
$mainli = $document->createElement("li");
$attribute = $document->createAttribute("class");
$mainli->appendChild($attribute);
$attribute->value = "toggle";
$mainul->appendChild($mainli);
if ($mainhref == "") {
$mainaspan = $document->createElement("span");
} else {
$mainaspan = $document->createElement("a");
$attribute = $document->createAttribute("href");
$mainaspan->appendChild($attribute);
$attribute->value = $mainhref;
}
$mainli->appendChild($mainaspan);
$mainaspan->nodeValue = $maintext;
// Build the submenu.
$submenu = $mainitem[2];
if (!$submenu) {
continue;
}
$this->submenu($document, $mainli, $submenu);
}
// Get the result.
$document->formatOutput = true;
$menu = $document->saveXML($mainul);
return $menu;
}
示例11: addPackage
/**
* Ajoute un paquet a la liste des paquets installes.
* @param Package $package Le paquet a ajouter.
*/
public function addPackage(Package $package)
{
//Si le paquet est deja installe, on enleve l'ancien
if ($this->isPackage($package->getName())) {
$oldPackage = $this->getPackage($package->getName());
$oldPackage->remove();
}
$xml = new \DOMDocument('1.0');
if ($this->webos->managers()->get('File')->exists($this->source . '/packages.xml')) {
$xml->loadXML($this->webos->managers()->get('File')->get($this->source . '/packages.xml')->contents());
$root = $xml->getElementsByTagName('packages')->item(0);
} else {
$root = $xml->createElement('packages');
$xml->appendChild($root);
}
$element = $xml->createElement('package');
$root->appendChild($element);
$name = $xml->createAttribute('name');
$name->appendChild($xml->createTextNode($package->getName()));
$element->appendChild($name);
$version = $xml->createAttribute('version');
$version->appendChild($xml->createTextNode($package->getVersion()->getVersion()));
$element->appendChild($version);
$this->webos->managers()->get('File')->get($this->source . '/packages.xml')->setContents($xml->saveXML());
$xml = new \DOMDocument('1.0');
$root = $xml->createElement('package');
$xml->appendChild($root);
$xml_attributes = $xml->createElement('attributes');
$root->appendChild($xml_attributes);
$attributes = $package->getAttributes();
$attributes['installed_time'] = time();
$attributes['source'] = $package->getRepositorySource();
foreach ($attributes as $attribute => $value) {
$node = $xml->createElement('attribute');
$xml_attributes->appendChild($node);
$name = $xml->createAttribute('name');
$name->appendChild($xml->createTextNode($attribute));
$node->appendChild($name);
$val = $xml->createAttribute('value');
$val->appendChild($xml->createTextNode($value));
$node->appendChild($val);
}
$files = $package->getFiles();
$xml_files = $xml->createElement('files');
$root->appendChild($xml_files);
foreach ($files as $file) {
$node = $xml->createElement('file');
$xml_files->appendChild($node);
$path = $xml->createAttribute('path');
$path->appendChild($xml->createTextNode($file));
$node->appendChild($path);
}
$this->webos->managers()->get('File')->createFile($this->source . '/packages/' . $package->getName() . '.xml')->setContents($xml->saveXML());
$newPackage = new InstalledPackage($this->webos, $this, $package->getName());
$this->packages[$package->getName()] = $newPackage;
}
示例12: __construct
/**
* SitemapGen constructor.
*/
public function __construct()
{
$this->dom = new DOMDocument();
$this->dom->formatOutput = true;
$this->root = $this->dom->createElement("urlset");
$this->dom->appendChild($this->root);
$rootAttr = $this->dom->createAttribute('xmlns');
$this->root->appendChild($rootAttr);
$rootAttrText = $this->dom->createTextNode('http://www.sitemaps.org/schemas/sitemap/0.9');
$rootAttr->appendChild($rootAttrText);
}
示例13: getCabec
function getCabec($versao)
{
$dom = new DOMDocument('1.0', 'utf-8');
$dom->formatOutput = false;
$raiz = $dom->appendChild($dom->createElement('cabecMsg'));
$raiz_att1 = $raiz->appendChild($dom->createAttribute('versao'));
$raiz_att1->appendChild($dom->createTextNode('1.02'));
$raiz_att2 = $raiz->appendChild($dom->createAttribute('xmlns'));
$raiz_att2->appendChild($dom->createTextNode('http://www.portalfiscal.inf.br/nfe'));
$raiz->appendChild($dom->createElement('versaoDados', $versao));
return $this->XML = $dom->saveXML();
}
示例14: createxml
public function createxml($array, $url)
{
$citysall = explode(";", $array['citys']);
if (is_array($citysall)) {
$dom2 = new DOMDocument('1.0', 'utf-8');
$path2 = $url . '/limitarea.xml';
@$dom2->load($path2);
//清空
$ads = $dom2->getElementsByTagName('address');
for ($a = 0; $a < $ads->length; $a++) {
$ad = $ads->item($a);
$ad->parentNode->removeChild($ad);
}
//清空
$address = $dom2->createElement('address');
$dom2->appendChild($address);
$path = IA_ROOT . '/addons/feng_fightgroups/template/amyarea.xml';
$xml = simplexml_load_file($path);
$provinces = $xml->province;
for ($i = 0; $i < count($provinces); $i++) {
$province = $provinces[$i];
foreach ($citysall as $key => $value) {
if ($province['name'] == $value) {
$shen = $dom2->createElement('province');
$name1 = $dom2->createAttribute('name');
$name1->nodeValue = $province['name'];
$shen->setAttributeNode($name1);
$address->appendChild($shen);
$citys = $province->city;
for ($j = 0; $j < count($citys); $j++) {
$city = $citys[$j];
$chen = $dom2->createElement('city');
$name2 = $dom2->createAttribute('name');
$name2->nodeValue = $city['name'];
$chen->setAttributeNode($name2);
$shen->appendChild($chen);
$countys = $city->county;
for ($k = 0; $k < count($countys); $k++) {
$county = $countys[$k];
$qu = $dom2->createElement('county');
$name3 = $dom2->createAttribute('name');
$name3->nodeValue = $county['name'];
$qu->setAttributeNode($name3);
$chen->appendChild($qu);
}
}
}
}
}
$dom2->save($path2);
}
}
示例15: geraXML
function geraXML()
{
$dom = new DOMDocument('1.0', 'utf-8');
$dom->formatOutput = false;
$EP01 = $dom->appendChild($dom->createElement('consSitNFe'));
$EP01_att1 = $EP01->appendChild($dom->createAttribute('versao'));
$EP01_att1->appendChild($dom->createTextNode($this->versao));
$EP01_att2 = $EP01->appendChild($dom->createAttribute('xmlns'));
$EP01_att2->appendChild($dom->createTextNode('http://www.portalfiscal.inf.br/nfe'));
$EP03 = $EP01->appendChild($dom->createElement('tpAmb', $this->tpAmb));
$EP04 = $EP01->appendChild($dom->createElement('xServ', $this->xServ));
$EP05 = $EP01->appendChild($dom->createElement('chNFe', $this->chNFe));
return $this->XML = $dom->saveXML();
}