本文整理汇总了PHP中XMLWriter::endAttribute方法的典型用法代码示例。如果您正苦于以下问题:PHP XMLWriter::endAttribute方法的具体用法?PHP XMLWriter::endAttribute怎么用?PHP XMLWriter::endAttribute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XMLWriter
的用法示例。
在下文中一共展示了XMLWriter::endAttribute方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: showResponse
/**
* @param array $params
* @param string $message
* @param int $code
*/
private function showResponse(array $params, $message = '', $code = 0)
{
header("Content-type: text/xml; charset=utf-8");
$writer = new XMLWriter();
$writer->openURI('php://output');
$writer->startDocument('1.0', 'UTF-8');
$writer->startElement($params['action'] . 'Response');
$writer->startAttribute('performedDatetime');
$writer->text(date('c'));
$writer->endAttribute();
$writer->startAttribute('code');
$writer->text($code);
$writer->endAttribute();
$writer->startAttribute('invoiceId');
$writer->text($params['invoiceId']);
$writer->endAttribute();
$writer->startAttribute('message');
$writer->text($message);
$writer->endAttribute();
$writer->startAttribute('shopId');
$writer->text($params['shopId']);
$writer->endAttribute();
$writer->endElement();
$writer->endDocument();
Yii::app()->end();
}
示例2: writeEntityInfo
/**
* Writes entity information in EDMX.
*
* @return void
*/
public function writeEntityInfo()
{
$this->xmlWriter->startElement(ODataConnectorForMySQLConstants::ENTITY_NAME_INFO);
foreach ($this->schema->entityNameInformation->entityNames as $entityName) {
$name = $this->replaceSpaces($entityName->dbName);
if ($this->schema->entityTypes["{$name}"]->viewable == true) {
$this->xmlWriter->startElement(ODataConnectorForMySQLConstants::ENTITY_NAME);
$this->xmlWriter->writeAttribute(ODataConnectorForMySQLConstants::DB_NAME, $entityName->dbName);
$this->xmlWriter->writeAttribute(ODataConnectorForMySQLConstants::ENTITY_TYPE_NAME, $entityName->entityTypeName);
$this->xmlWriter->writeAttribute(ODataConnectorForMySQLConstants::ENTITY_SET_NAME, $entityName->entitySetName);
$this->xmlWriter->endAttribute();
$this->xmlWriter->endElement();
}
}
$this->xmlWriter->endElement();
}
示例3: array_to_xml
/**
* Convert array into XML by recursively generating child elements
*
* First instantiate a new XML writer object:
*
* $xml = new XMLWriter();
*
* Open in memory (alternatively you can use a local URI for file output)
*
* $xml->openMemory();
*
* Then start the document
*
* $xml->startDocument( '1.0', 'UTF-8' );
*
* Don't forget to end the document and output the memory
*
* $xml->endDocument();
*
* $your_xml_string = $xml->outputMemory();
*
* @since 2.2.0
* @param \XMLWriter $xml_writer XML writer instance
* @param string|array $element_key name for element, e.g. <per_page>
* @param string|array $element_value value for element, e.g. 100
* @return string generated XML
*/
public static function array_to_xml($xml_writer, $element_key, $element_value = array())
{
if (is_array($element_value)) {
// handle attributes
if ('@attributes' === $element_key) {
foreach ($element_value as $attribute_key => $attribute_value) {
$xml_writer->startAttribute($attribute_key);
$xml_writer->text($attribute_value);
$xml_writer->endAttribute();
}
return;
}
// handle multi-elements (e.g. multiple <Order> elements)
if (is_numeric(key($element_value))) {
// recursively generate child elements
foreach ($element_value as $child_element_key => $child_element_value) {
$xml_writer->startElement($element_key);
foreach ($child_element_value as $sibling_element_key => $sibling_element_value) {
self::array_to_xml($xml_writer, $sibling_element_key, $sibling_element_value);
}
$xml_writer->endElement();
}
} else {
// start root element
$xml_writer->startElement($element_key);
// recursively generate child elements
foreach ($element_value as $child_element_key => $child_element_value) {
self::array_to_xml($xml_writer, $child_element_key, $child_element_value);
}
// end root element
$xml_writer->endElement();
}
} else {
// handle single elements
if ('@value' == $element_key) {
$xml_writer->text($element_value);
} else {
// wrap element in CDATA tags if it contains illegal characters
if (false !== strpos($element_value, '<') || false !== strpos($element_value, '>')) {
$xml_writer->startElement($element_key);
$xml_writer->writeCdata($element_value);
$xml_writer->endElement();
} else {
$xml_writer->writeElement($element_key, $element_value);
}
}
return;
}
}
示例4: createPageMetadata
private function createPageMetadata($strPageId, XMLWriter $objWriter)
{
//loop all languages if given
$objLanguages = new class_module_languages_language();
$strCurrentLanguage = $objLanguages->getStrAdminLanguageToWorkOn();
$arrLanguages = class_module_languages_language::getObjectList();
foreach ($arrLanguages as $objOneLanguage) {
$objLanguages->setStrAdminLanguageToWorkOn($objOneLanguage->getStrName());
$objPage = new class_module_pages_page($strPageId);
$objWriter->startElement("propertyset");
$objWriter->startAttribute("language");
$objWriter->text($objOneLanguage->getStrName());
$objWriter->endAttribute();
$objWriter->startElement("browsername");
$objWriter->text($objPage->getStrBrowsername());
$objWriter->endElement();
$objWriter->startElement("description");
$objWriter->text($objPage->getStrDesc());
$objWriter->endElement();
$objWriter->startElement("keywords");
$objWriter->text($objPage->getStrKeywords());
$objWriter->endElement();
$objWriter->startElement("template");
$objWriter->text($objPage->getStrTemplate());
$objWriter->endElement();
$objWriter->startElement("seostring");
$objWriter->text($objPage->getStrSeostring());
$objWriter->endElement();
$objWriter->startElement("language");
$objWriter->text($objPage->getStrLanguage());
$objWriter->endElement();
$objWriter->startElement("alias");
$objWriter->text($objPage->getStrAlias());
$objWriter->endElement();
$objWriter->startElement("path");
$objWriter->text($objPage->getStrPath());
$objWriter->endElement();
$objWriter->startElement("target");
$objWriter->text($objPage->getStrTarget());
$objWriter->endElement();
//propertyset
$objWriter->endElement();
}
$objLanguages->setStrAdminLanguageToWorkOn($strCurrentLanguage);
}
示例5: generateXML
/**
* Generates and returns the XML required by the eMobilePlatform API.
*
* @param string $groupName The family of functions to access.
* @param string $methodName The specific operation to preform.
* @param array|null $params An optional array of parameters.
* @return string The returned XML as a string.
* @throws \InvalidArgumentException
*/
private function generateXML($groupName, $methodName, $params = null)
{
if (!is_string($groupName) || !is_string($methodName) || !is_array($params) && $params !== null) {
throw new \InvalidArgumentException('Invalid Arguments Supplied');
}
$xmlWriter = new \XMLWriter();
$xmlWriter->openMemory();
$xmlWriter->startDocument('1.0', 'UTF-8');
$xmlWriter->setIndent(4);
$xmlWriter->startElement('operation');
$xmlWriter->writeAttribute('api_version', '1.0');
$xmlWriter->writeAttribute('type', 'submit');
/* Writes the auth element section. */
$xmlWriter->startElement('auth');
$xmlWriter->writeAttribute('username', $this->username);
$xmlWriter->writeAttribute('api_key', $this->apiKey);
$xmlWriter->endElement();
/* Writes the action element section. */
$xmlWriter->startElement('action');
$xmlWriter->writeAttribute('group', $groupName);
$xmlWriter->writeAttribute('method', $methodName);
$xmlWriter->endElement();
/* Writes the optional param element. */
$xmlWriter->startElement('param');
if ($params !== null) {
$xmlWriter->writeAttribute('null', 'false');
foreach ($params as $key => $value) {
if (is_array($value)) {
foreach ($value as $item) {
$xmlWriter->startElement($key);
$xmlWriter->writeAttribute('type', gettype($item));
$xmlWriter->endAttribute();
$xmlWriter->text($item);
$xmlWriter->endElement();
}
} else {
$xmlWriter->startElement($key);
$xmlWriter->writeAttribute('type', gettype($value));
$xmlWriter->endAttribute();
$xmlWriter->text($value);
$xmlWriter->endElement();
}
}
} else {
$xmlWriter->writeAttribute('null', 'true');
}
/* Close the optional data element. */
$xmlWriter->endElement();
/* Close the response element. */
$xmlWriter->endElement();
/* End the XML document. */
$xmlWriter->endDocument();
$xml = $xmlWriter->outputMemory(true);
return $xml;
}
示例6: endAttribute
/**
* End attribute
*
* @param string $name
*/
public function endAttribute($name)
{
$this->checkEndAttribute($name);
$this->xmlWriter->endAttribute();
}
示例7: function
/* Codeine
* @author bergstein@trickyplan.com
* @description: Simple HTML Renderer
* @package Codeine
* @version 8.x
*/
setFn('Render', function ($Call) {
$Call = F::Hook('beforeRSSPipeline', $Call);
$XML = new XMLWriter();
$XML->openMemory();
$XML->startDocument('1.0', 'UTF-8');
$XML->setIndent(true);
$XML->startElement('rss');
$XML->startAttribute('version');
$XML->text('2.0');
$XML->endAttribute();
$XML->startElement('channel');
$XML->writeElement('title', $Call['Project']['Title']);
// FIXME
$XML->writeElement('link', $Call['HTTP']['Proto'] . $Call['HTTP']['Host'] . $Call['Link']);
if (isset($Call['Page']['Description'])) {
$XML->writeElement('description', $Call['Page']['Description']);
} else {
$XML->writeElement('description', '');
}
$XML->writeElement('generator', 'Codeine ' . $Call['Version']['Codeine']['Major']);
$XML->writeElement('pubDate', date(DATE_RSS, time()));
$XML->writeElement('lastBuildDate', date(DATE_RSS, time()));
if (!isset($Call['Slug'])) {
$Call['Slug'] = strtolower($Call['Entity']);
}
示例8: save
/**
* Saves the result document.
*
* @return string
* @throws \PhpOffice\PhpWord\Exception\Exception
*/
public function save()
{
foreach ($this->temporaryDocumentHeaders as $index => $headerXML) {
$this->zipClass->addFromString($this->getHeaderName($index), $this->temporaryDocumentHeaders[$index]);
}
$this->zipClass->addFromString('word/document.xml', $this->temporaryDocumentMainPart);
$word = new Word2007();
$read = $word->readRelationships($this->zipClass->filename);
if (count($this->imageData)) {
$read['document'] = array_merge($read['document'], $this->imageData);
$xml = new \XMLWriter();
$xml->openMemory();
$xml->setIndent(true);
$xml->startDocument('1.0', 'UTF-8');
$xml->startElement('Relationships');
$xml->startAttribute('xmlns');
$xml->text('http://schemas.openxmlformats.org/package/2006/relationships');
$xml->endAttribute();
foreach ($read['document'] as $key => $data) {
$xml->startElement('Relationship');
$xml->startAttribute('Id');
$xml->text($key);
$xml->endAttribute();
$xml->startAttribute('Type');
$xml->text('http://schemas.openxmlformats.org/officeDocument/2006/relationships/' . $data['type']);
$xml->endAttribute();
$xml->startAttribute('Target');
$xml->text($data['type'] === 'image' ? $data['docPart'] : $data['docPart'] . '.xml');
$xml->endAttribute();
$xml->endElement();
}
$xml->endElement();
$xml->endDocument();
$this->zipClass->addFromString('word/_rels/document.xml.rels', $xml->outputMemory(true));
}
foreach ($this->temporaryDocumentFooters as $index => $headerXML) {
$this->zipClass->addFromString($this->getFooterName($index), $this->temporaryDocumentFooters[$index]);
}
// Close zip file
if (false === $this->zipClass->close()) {
throw new Exception('Could not close zip file.');
}
return $this->temporaryDocumentFilename;
}
示例9: serializeException
/**
* Serialize the exception
*
* @param ODataException $exception Exception to serialize
* @param boolean $serializeInnerException if set to true,
* serialize the inner exception if $exception is an ODataException.
*
* @return string
*/
public static function serializeException(ODataException $exception, $serializeInnerException)
{
$xmlWriter = new \XMLWriter();
$xmlWriter->openMemory();
$xmlWriter->startDocument('1.0', 'UTF-8', 'yes');
$xmlWriter->setIndent(4);
$xmlWriter->startElement(ODataConstants::XML_ERROR_ELEMENT_NAME);
//$xmlWriter->writeAttributeNs(
// ODataConstants::XMLNS_NAMESPACE_PREFIX,
// ODataConstants::XML_NAMESPACE_PREFIX,
// ODataConstants::XML_NAMESPACE,
// null
//);
$xmlWriter->writeAttribute(ODataConstants::XMLNS_NAMESPACE_PREFIX, ODataConstants::ODATA_METADATA_NAMESPACE);
$xmlWriter->endAttribute();
$xmlWriter->startElement(ODataConstants::XML_ERROR_CODE_ELEMENT_NAME);
if ($exception->getCode() != null) {
$xmlWriter->text($exception->getCode());
}
$xmlWriter->endElement();
$xmlWriter->startElement(ODataConstants::XML_ERROR_MESSAGE_ELEMENT_NAME);
$xmlWriter->text($exception->getMessage());
$xmlWriter->endElement();
$xmlWriter->endElement();
$xmlWriter->endDocument();
return $xmlWriter->outputMemory(true);
}
示例10: ExportToRss
/**
* Used to export the given data as rss feed
*
* It returns a xml data string containing rss feed data
*
* @link http://www.w3schools.com/xml/xml_syntax.asp
* @param array $data the data to be exported to rss format
* @param array $xml_namespace the xml namespace for the document
* prefix => string the xml namespace prefix
* name => string the xml namespace name
* uri => string the xml namespace uri
* @param array $namespace_attributes the list of tags that need to be prefixed with namespace
*
* @return string $rss_file the contents of the rss file
*/
public function ExportToRss($data, $xml_namespace, $namespace_attributes)
{
/** The XMLWriter class object is created. The XMLWriter php extension is enabled by default */
$writer = new \XMLWriter();
$writer->openMemory();
/** The xml prolog is added */
$writer->startDocument('1.0', 'UTF-8');
$writer->setIndent(true);
$writer->startAttributeNS($xml_namespace['prefix'], $xml_namespace['name'], $xml_namespace['uri']);
/** The rss tag is opened */
$writer->startElement('rss');
$writer->startAttribute('version');
$writer->text('2.0');
$writer->endAttribute();
$writer->startElement('channel');
/** Each Item is added to the rss feed */
for ($count = 0; $count < count($data); $count++) {
$data_item = $data[$count];
$writer->startElement('item');
/** Xml tag is created for each data item */
foreach ($data_item as $tag_name => $tag_value) {
/** If the tag name is in the list of tags that need to be prefixed with namespace */
if (in_array($tag_name, $namespace_attributes)) {
/** The namespace is added to the tag name */
$tag_name = $xml_namespace['name'] . ":" . $tag_name;
}
$writer->startElement($tag_name);
$writer->text($tag_value);
$writer->endElement();
}
$writer->endElement();
}
$writer->endElement();
$writer->endElement();
$writer->endDocument();
/** The xml data is exported to string */
$rss_file = $writer->outputMemory(TRUE);
return $rss_file;
}
示例11: XMLWriter
<?php
/* $Id$ */
$xw = new XMLWriter();
$xw->openMemory();
$xw->setIndent(TRUE);
$xw->setIndentString(' ');
$xw->startDocument('1.0', "UTF-8");
$xw->startElement('root');
$xw->startElementNS('ns1', 'child1', 'urn:ns1');
$xw->startAttributeNS('ns1', 'att1', 'urn:ns1');
$xw->text('a&b');
$xw->endAttribute();
$xw->writeAttribute('att2', "double\" single'");
$xw->startAttributeNS('ns1', 'att2', 'urn:ns1');
$xw->text("<>\"'&");
$xw->endAttribute();
$xw->writeElement('chars', "special characters: <>\"'&");
$xw->endElement();
$xw->endDocument();
// Force to write and empty the buffer
$output = $xw->flush(true);
print $output;
示例12: count
print "Connect failed: " . $mysqli->connect_error . "\n";
exit;
}
/* set character set */
if (!$mysqli->set_charset("utf8")) {
print "Error loading character set utf8: " . $mysqli->error;
exit;
}
$sql = "\n\t\tSELECT\n\t\t\tl_make as vendor,\n\t\t\tl_model,\n\t\t\tl_geo_city as geo,\n\t\t\tcount(*) as num,\n\t\t\tsum(if(cmp_rank is null,0,1)) as promoted,\n\t\t\tif((sum(if(cmp_rank is null,0,1)) / count(*)) > 0.6,'true','false') as flag,\n\t\t\tl_subcategory as category,\n\t\t\tif(l_isdealer=1,'new','used') as `type`,\n\t\t\tconcat(\n\t\t\t\t'http://vehicles.pingola.ru/search/транспорт/',\n\t\t\t\tl_geo_city,\n\t\t\t\t'/?make=',\n\t\t\t\tl_make,\n\t\t\t\t'&model=',\n\t\t\t\tl_model,\n\t\t\t\tif(l_subcategory<>'','&bodytype=',''),\n\t\t\t\tl_subcategory,\n\t\t\t\tif(l_isdealer=1,'&type=Новые','&type=Подержанные')\n\t\t\t) as link\n\t\tFROM ru_eyezeek.vehicles v\n\t\t\tleft join ru_eyezeek.promoted_vehicles p on v.l_id=p.o_l_id\n\t\twhere l_isactive=1 and l_make<>'' and l_model<>'' and l_geo_city<>''\n\t\tgroup by l_make,l_model,l_geo_city,l_subcategory,l_isdealer\n\t\torder by num desc limit 10000";
if ($result = $mysqli->query($sql)) {
$writer = new XMLWriter();
$writer->openURI('/home/eyezeek/netup/ru/context_rk/context_rk.xml');
$writer->startDocument('1.0', 'UTF-8');
$writer->setIndent(TRUE);
$writer->startElement('ROOT');
$writer->writeElement('CreationDate', date("d/m/y : H:i:s", time()));
while ($arr = $result->fetch_assoc()) {
$writer->startElement('row');
foreach ($arr as $name => $value) {
$writer->startElement('field');
$writer->startAttribute('name');
$writer->text($name);
$writer->endAttribute();
$writer->text($value);
$writer->endElement();
}
$writer->endElement();
}
$writer->endDocument();
$writer->flush();
}