本文整理汇总了PHP中XMLWriter::writeElementNS方法的典型用法代码示例。如果您正苦于以下问题:PHP XMLWriter::writeElementNS方法的具体用法?PHP XMLWriter::writeElementNS怎么用?PHP XMLWriter::writeElementNS使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XMLWriter
的用法示例。
在下文中一共展示了XMLWriter::writeElementNS方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: main
function main()
{
$x = new XMLWriter();
$x->openMemory();
$x->setIndent(true);
$x->startDocument('1.0');
$x->startElementNS(null, 'startNullPrefix', null);
$x->startElementNS('', 'startEmptyPrefix', null);
$x->writeElementNS(null, 'writeNullPrefix', null);
$x->writeElementNS('', 'writeEmptyPrefix', null);
$x->endElement();
$x->endElement();
$x->endDocument();
var_dump($x->outputMemory(true));
}
示例2: write
public function write(\XMLWriter $writer, \DateTimeZone $timezone, $stringTag)
{
if (strpos(static::XMLRPC_TYPE, '}') !== false) {
list($ns, $tagName) = explode('}', static::XMLRPC_TYPE, 2);
$ns = (string) substr($ns, 1);
return $writer->writeElementNS('ex', $tagName, $ns, gmp_strval($this->value));
}
return $writer->writeElement(static::XMLRPC_TYPE, gmp_strval($this->value));
}
示例3: write
public function write(\XMLWriter $writer, \DateTimeZone $timezone, $stringTag)
{
// PHP has serious issues with timezone handling.
// As a workaround, we use format(), specifying a UNIX timestamp
// as the format to use, which we then reinject in a new DateTime.
$date = new \DateTime('@' . $this->value->format('U'), $timezone);
if (strpos(static::XMLRPC_TYPE, '}') !== false) {
list($ns, $tagName) = explode('}', static::XMLRPC_TYPE, 2);
$ns = (string) substr($ns, 1);
return $writer->writeElementNS('ex', $tagName, $ns, $date->format(static::XMLRPC_FORMAT));
}
return $writer->writeElement(static::XMLRPC_TYPE, $date->format(static::XMLRPC_FORMAT));
}
示例4: linkDeliveryPolicyToAsset
/**
* Link AssetDeliveryPolicy to Asset
*
* @param Models\Asset|string $asset Asset to link a AssetDeliveryPolicy or
* Asset id
*
* @param Models\AssetDeliveryPolicy|string $policy DeliveryPolicy to link or
* DeliveryPolicy id
*
* @return void
*/
public function linkDeliveryPolicyToAsset($asset, $policy)
{
$assetId = Utilities::getEntityId($asset, 'WindowsAzure\\MediaServices\\Models\\Asset');
$assetId = urlencode($assetId);
$policyId = Utilities::getEntityId($policy, 'WindowsAzure\\MediaServices\\Models\\AssetDeliveryPolicy');
$policyId = urlencode($policyId);
$contentWriter = new \XMLWriter();
$contentWriter->openMemory();
$contentWriter->writeElementNS('data', 'uri', Resources::DS_XML_NAMESPACE, $this->getUri() . "AssetDeliveryPolicies('{$policyId}')");
$method = Resources::HTTP_POST;
$path = "Assets('{$assetId}')/\$links/DeliveryPolicies";
$headers = array(Resources::CONTENT_TYPE => Resources::XML_CONTENT_TYPE);
$postParams = array();
$queryParams = array();
$statusCode = Resources::STATUS_NO_CONTENT;
$body = $contentWriter->outputMemory();
$this->send($method, $headers, $postParams, $queryParams, $path, $statusCode, $body);
}
示例5: xmlwriter_flush
<?php
$xw = xmlwriter_open_memory();
xmlwriter_set_indent($xw, true);
xmlwriter_start_document($xw);
xmlwriter_start_element_ns($xw, 'test', 'test', 'urn:x-test:');
xmlwriter_write_element_ns($xw, 'test', 'foo', null, '');
xmlwriter_write_element_ns($xw, null, 'bar', 'urn:x-test:', '');
xmlwriter_write_element_ns($xw, null, 'bar', '', '');
xmlwriter_end_element($xw);
xmlwriter_end_document($xw);
print xmlwriter_flush($xw, true);
print "\n";
$xw = new XMLWriter();
$xw->openMemory();
$xw->setIndent(true);
$xw->startDocument();
$xw->startElementNS('test', 'test', 'urn:x-test:');
$xw->writeElementNS('test', 'foo', null, '');
$xw->writeElementNS(null, 'bar', 'urn:x-test:', '');
$xw->writeElementNS(null, 'bar', '', '');
$xw->endElement();
$xw->endDocument();
print $xw->flush(true);
示例6: writeCatalog
/**
* Construct the catalog entry
*
* @param XmlWriter $xml XML stream to write to
* @param array $data data-blob of i18n and config variables
* @param array $dataset array of the dataset identifiers
*/
function writeCatalog(XMLWriter $xml, array $data, array $dataset)
{
$xml->startElementNS('rdf', 'Description', null);
$xml->writeAttributeNS('rdf', 'about', null, $data['config']['uri'] . '#catalog');
$xml->startElementNS('rdf', 'type', null);
$xml->writeAttributeNS('rdf', 'resource', null, 'http://www.w3.org/ns/dcat#Catalog');
$xml->endElement();
$xml->startElementNS('dcterms', 'license', null);
$xml->writeAttributeNS('rdf', 'resource', null, $data['config']['catalog-license']);
$xml->endElement();
$xml->startElementNS('dcat', 'themeTaxonomy', null);
$xml->writeAttributeNS('rdf', 'resource', null, 'http://eurovoc.europa.eu/');
$xml->endElement();
$xml->writeElementNS('foaf', 'homepage', null, $data['config']['catalog-homepage']);
$xml->startElementNS('dcterms', 'modified', null);
$xml->writeAttributeNS('rdf', 'datatype', null, 'http://www.w3.org/2001/XMLSchema#date');
$xml->text(date('Y-m-d'));
$xml->endElement();
$xml->startElementNS('dcterms', 'issued', null);
$xml->writeAttributeNS('rdf', 'datatype', null, 'http://www.w3.org/2001/XMLSchema#date');
$xml->text($data['config']['catalog-issued']);
$xml->endElement();
$xml->startElementNS('dcterms', 'publisher', null);
$xml->writeAttributeNS('rdf', 'nodeID', null, $data['ids']['publisher']);
$xml->endElement();
// add language, title and description in each language
writeCatalogI18n($xml, $data);
// add datasets
foreach ($dataset as $key => $value) {
$xml->startElementNS('dcat', 'dataset', null);
$xml->writeAttributeNS('rdf', 'resource', null, $value);
$xml->endElement();
}
$xml->endElement();
}
示例7: write
public function write(\XMLWriter $writer, \DateTimeZone $timezone, $stringTag)
{
return $writer->writeElementNS('ex', 'nil', 'http://ws.apache.org/xmlrpc/namespaces/extensions');
}
示例8: file_get_contents
<?php
/* $Id$ */
$doc_dest = '001.xml';
$xw = new XMLWriter();
$xw->openUri($doc_dest);
$xw->startDtd('foo', NULL, 'urn:bar');
$xw->endDtd();
$xw->startElement('foo');
$xw->writeElementNS('foo', 'bar', 'urn:foo', 'dummy content');
$xw->endElement();
// Force to write and empty the buffer
$output_bytes = $xw->flush(true);
echo file_get_contents($doc_dest);
unset($xw);
unlink('001.xml');
示例9: format
//.........这里部分代码省略.........
$xml->text($node['name']);
$xml->startElementNS('y', 'LabelModel', null);
$xml->startElementNS('y', 'SmartNodeLabelModel', null);
$xml->writeAttribute('distance', '4.0');
$xml->endElement();
// y:SmartModeLabelModel
$xml->endElement();
// y:LabelModel
$xml->startElementNS('y', 'ModelParameter', null);
$xml->startElementNS('y', 'SmartNodeLabelModelParameter', null);
$xml->writeAttribute('labelRatioX', '0.0');
$xml->writeAttribute('labelRatioY', '0.0');
$xml->writeAttribute('nodeRatioX', '0.0');
// Necessary?
$xml->writeAttribute('nodeRatioY', '-0.03703090122767855');
// Necessary?
$xml->writeAttribute('offsetX', '0.0');
$xml->writeAttribute('offsetY', '0.0');
$xml->writeAttribute('upX', '0.0');
$xml->writeAttribute('upY', '-1.0');
$xml->endElement();
// y:SmartNodeLabelModelParameter
$xml->endElement();
// y:ModelParameter
$xml->endElement();
// y:NodeLabel
$xml->startElementNS('y', 'UML', null);
$xml->writeAttribute('clipContent', 'true');
$xml->writeAttribute('constraint', '');
$xml->writeAttribute('omitDetails', 'false');
$xml->writeAttribute('stereotype', $node['stereotype']);
$xml->writeAttribute('use3DEffect', 'true');
// TODO: uml attribs
$xml->writeElementNS('y', 'AttributeLabel', null);
// TODO: uml operations
$xml->writeElementNS('y', 'MethodLabel', null);
$xml->endElement();
// y:UML
$xml->endElement();
// y:UMLClassNode
$xml->endElement();
// data
$xml->endElement();
// node
}
// Edges
foreach ($graph->edges as $edge) {
$xml->startElement('edge');
$xml->writeAttribute('source', $edge['source']);
$xml->writeAttribute('target', $edge['target']);
$xml->startElement('data');
$xml->writeAttribute('key', 'edge_url');
$xml->endElement();
// data
$xml->startElement('data');
$xml->writeAttribute('key', 'edge_description');
$xml->endElement();
// data
$xml->startElement('data');
$xml->writeAttribute('key', 'edge_graphics');
$xml->startElementNS('y', 'PolyLineEdge', null);
// Path
$xml->startElementNS('y', 'Path', null);
$xml->writeAttribute('sx', '0.0');
$xml->writeAttribute('sy', '0.0');
$xml->writeAttribute('tx', '0.0');
示例10: writeElementNS
/**
* @param string $prefix
* @param string $name
* @param string $uri
* @param null|string $content
* @return bool
*/
public function writeElementNS($prefix, $name, $uri = null, $content = null)
{
if (!$this->hasNSPrefix($prefix)) {
$this->nsArray[$prefix] = $uri;
}
return parent::writeElementNS($prefix, $name, $uri, $content);
}