本文整理汇总了PHP中XMLWriter类的典型用法代码示例。如果您正苦于以下问题:PHP XMLWriter类的具体用法?PHP XMLWriter怎么用?PHP XMLWriter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了XMLWriter类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: Voice
public function Voice($MediaId)
{
$w = new \XMLWriter();
$w->openMemory();
$w->writeElement('MediaId', $MediaId);
$this->add('Voice', $w->outputMemory(), true);
}
开发者ID:jesse-jitao,项目名称:weixin-sdk,代码行数:7,代码来源:MessageBuilder.php
示例2: setElementFromArray
public function setElementFromArray(XMLWriter $xml, $rootNode, array $config)
{
$config = $this->normalize($config);
if (!empty($config)) {
foreach ($config as $key => $val) {
$numeric = 0;
if (is_numeric($key)) {
$numeric = 1;
$key = $rootNode;
}
if (is_array($val)) {
$isAssoc = $this->isAssoc($val);
if ($isAssoc || $numeric) {
$xml->startElement($key);
}
$this->setElementFromArray($xml, $key, $val);
if ($isAssoc || $numeric) {
$xml->endElement();
}
continue;
}
$xml->writeElement($key, $val);
}
}
}
开发者ID:jeremykendall,项目名称:spaz-api,代码行数:25,代码来源:XmlArrayWriter.php
示例3: _arr2xml
/**
* Takes an array and produces XML based on it.
*
* @param XMLWriter $xmlw XMLWriter object that was previously instanted
* and is used for creating the XML.
* @param array $data Array to be converted to XML.
* @param string $defaultTag Default XML tag to be used if none specified.
*
* @return void
*/
private function _arr2xml(\XMLWriter $xmlw, $data, $defaultTag = null)
{
foreach ($data as $key => $value) {
if ($key === Resources::XTAG_ATTRIBUTES) {
foreach ($value as $attributeName => $attributeValue) {
$xmlw->writeAttribute($attributeName, $attributeValue);
}
} else {
if (is_array($value)) {
if (!is_int($key)) {
if ($key != Resources::EMPTY_STRING) {
$xmlw->startElement($key);
} else {
$xmlw->startElement($defaultTag);
}
}
$this->_arr2xml($xmlw, $value);
if (!is_int($key)) {
$xmlw->endElement();
}
} else {
$xmlw->writeElement($key, $value);
}
}
}
}
开发者ID:bitmovin,项目名称:azure-sdk-for-php,代码行数:36,代码来源:XmlSerializer.php
示例4: write
public function write(PlatformInterface $platform, \XMLWriter $xmlWriter)
{
$xmlWriter->startElement('video:platform');
$xmlWriter->writeAttribute('relationship', $platform->relationship());
$xmlWriter->text(implode(' ', $platform->types()));
$xmlWriter->endElement();
}
开发者ID:refinery29,项目名称:sitemap,代码行数:7,代码来源:PlatformWriter.php
示例5: _internalRender
protected function _internalRender($name)
{
$vars = $this->getVars();
$file = $this->getStream();
if ($file === false) {
throw new GlobalServiceException("Impossible to create xml file");
}
// Start response object
fputs($file, '<?xml version="1.0" encoding="UTF-8"?><response>');
// Temp memory
$memXml = new XMLWriter();
$memXml->openMemory();
$memXml->setIndent(true);
if (isset($vars['count']) && $this->_countKey) {
$this->_writeXmlElem($memXml, $this->_countKey, (int) $vars['count']);
fputs($file, $memXml->outputMemory());
}
// Designed for lists only!!!
if (!empty($vars['data']) && count($vars['data']) && $this->_dataKey) {
fputs($file, '<' . $this->_dataKey . '>');
foreach ($vars['data'] as $k => $v) {
$v = $this->_filterData($v);
if ($this->_skipEmptyItems && empty($v)) {
continue;
}
$this->_writeXmlElem($memXml, $k, $v);
fputs($file, $memXml->outputMemory());
}
fputs($file, '</' . $this->_dataKey . '>');
}
// End response object
fputs($file, '</response>');
}
开发者ID:SandeepUmredkar,项目名称:PortalSMIP,代码行数:33,代码来源:Xml.php
示例6: write
/**
* @param XMLWriter $xml
* @param $data
*/
public static function write(XMLWriter $xml, $data)
{
foreach ($data as $key => $value) {
if (is_array($value) && isset($value[0])) {
foreach ($value as $itemValue) {
//$xml->writeElement($key, $itemValue);
if (is_array($itemValue)) {
$xml->startElement($key);
self::write($xml, $itemValue);
$xml->endElement();
continue;
}
if (!is_array($itemValue)) {
$xml->writeElement($key, $itemValue . "");
}
}
} else {
if (is_array($value)) {
$xml->startElement($key);
self::write($xml, $value);
$xml->endElement();
continue;
}
}
if (!is_array($value)) {
$xml->writeElement($key, $value . "");
}
}
}
开发者ID:dafik,项目名称:dfi,代码行数:33,代码来源:Xml.php
示例7: write
public function write(RestrictionInterface $restriction, \XMLWriter $xmlWriter)
{
$xmlWriter->startElement('video:restriction');
$xmlWriter->writeAttribute('relationship', $restriction->relationship());
$xmlWriter->text(implode(' ', $restriction->countryCodes()));
$xmlWriter->endElement();
}
开发者ID:refinery29,项目名称:sitemap,代码行数:7,代码来源:RestrictionWriter.php
示例8: writeNamespaceAttributes
private function writeNamespaceAttributes(\XMLWriter $xmlWriter)
{
$xmlWriter->writeAttribute(UrlSetInterface::XML_NAMESPACE_ATTRIBUTE, UrlSetInterface::XML_NAMESPACE_URI);
$xmlWriter->writeAttribute(ImageInterface::XML_NAMESPACE_ATTRIBUTE, ImageInterface::XML_NAMESPACE_URI);
$xmlWriter->writeAttribute(NewsInterface::XML_NAMESPACE_ATTRIBUTE, NewsInterface::XML_NAMESPACE_URI);
$xmlWriter->writeAttribute(VideoInterface::XML_NAMESPACE_ATTRIBUTE, VideoInterface::XML_NAMESPACE_URI);
}
开发者ID:refinery29,项目名称:sitemap,代码行数:7,代码来源:UrlSetWriter.php
示例9: getItem
protected function getItem()
{
$xml = new \XMLWriter();
$xml->openMemory();
$xml->setIndent(true);
$item = new Price($xml);
return $item;
}
开发者ID:pfeyssaguet,项目名称:guzzle-aws,代码行数:8,代码来源:AbstractFeedItemTest.php
示例10: writeXml
/**
* Write XML to output
*
* @param \XMLWriter $xml
* @param string $nodeName
*
* @return CurrencyAmount
*/
public function writeXml(\XMLWriter $xml, $nodeName)
{
$xml->startElement($nodeName);
$xml->writeAttribute('currency', $this->get('baseCurrencyCode'));
$xml->text($this->get('value'));
$xml->endElement();
return $this;
}
开发者ID:pfeyssaguet,项目名称:guzzle-aws,代码行数:16,代码来源:CurrencyAmount.php
示例11: generateXML
private function generateXML(XmlEntityInterface $xmlEntity)
{
$xmlWriter = new \XMLWriter();
$xmlWriter->openMemory();
$xmlWriter->setIndent(false);
$xmlEntity->toXML($xmlWriter);
return $xmlWriter->outputMemory(true);
}
开发者ID:lucasmro,项目名称:clearsale,代码行数:8,代码来源:AddressTest.php
示例12: writeXML
public function writeXML(\XMLWriter $xmlWriter)
{
if ($this->mailAttributes != NULL) {
$xmlWriter->startELement(Constants::MESSAGE_ATTRIBUTES);
$this->mailAttributes->writeXML($xmlWriter);
$xmlWriter->endElement();
}
}
开发者ID:yunwuxin,项目名称:aliyun_mns,代码行数:8,代码来源:MessageAttributes.php
示例13: write
public function write(\XMLWriter $writer, \DateTimeZone $timezone, $stringTag)
{
if ($stringTag) {
$writer->writeElement('string', $this->value);
} else {
$writer->text($this->value);
}
}
开发者ID:fpoirotte,项目名称:xrl,代码行数:8,代码来源:StringType.php
示例14: encodeXml
public static function encodeXml($var)
{
$xmlWriter = new \XMLWriter();
$xmlWriter->openMemory();
$xmlWriter->setIndent(true);
$xmlWriter->startDocument('1.0', 'UTF-8');
self::encodeXmlNode($xmlWriter, 'root', $var);
return $xmlWriter->flush();
}
开发者ID:rousseau-christopher,项目名称:equinox-core,代码行数:9,代码来源:AjaxUtil.php
示例15: writeXML
public function writeXML(\XMLWriter $xmlWriter)
{
if ($this->maximumMessageSize != NULL) {
$xmlWriter->writeElement(Constants::MAXIMUM_MESSAGE_SIZE, $this->maximumMessageSize);
}
if ($this->messageRetentionPeriod != NULL) {
$xmlWriter->writeElement(Constants::MESSAGE_RETENTION_PERIOD, $this->messageRetentionPeriod);
}
}
开发者ID:lizhengqiang,项目名称:thinkphp,代码行数:9,代码来源:TopicAttributes.php
示例16: testSetCarrierCode
public function testSetCarrierCode()
{
$xml = new \XMLWriter();
$xml->openMemory();
$xml->setIndent(true);
$f = new OrderFulfillment($xml);
$this->setExpectedException('InvalidArgumentException');
$f->setCarrierCode('Foo');
}
开发者ID:pfeyssaguet,项目名称:guzzle-aws,代码行数:9,代码来源:OrderFulfillmentTest.php
示例17: writeLastModified
private function writeLastModified(\XMLWriter $xmlWriter, \DateTimeInterface $lastModified = null)
{
if ($lastModified === null) {
return;
}
$xmlWriter->startElement('lastmod');
$xmlWriter->text($lastModified->format('c'));
$xmlWriter->endElement();
}
开发者ID:refinery29,项目名称:sitemap,代码行数:9,代码来源:SitemapWriter.php
示例18: build
public function build($name, $node, \XMLWriter &$writer, $under_root)
{
// always inside an xsd:element
$writer->startElementNs('xsd', 'element', null);
$writer->writeAttribute('name', $name);
$this->addRequired($node, $writer, $under_root);
$writer->writeAttribute('type', 'xsd:boolean');
$writer->endElement();
}
开发者ID:romaricdrigon,项目名称:metayaml,代码行数:9,代码来源:XsdBooleanNodeGenerator.php
示例19: 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));
}
开发者ID:fpoirotte,项目名称:xrl,代码行数:9,代码来源:AbstractInteger.php
示例20: testSetImageType
public function testSetImageType()
{
$xml = new \XMLWriter();
$xml->openMemory();
$xml->setIndent(true);
$image = new Image($xml);
$this->setExpectedException('InvalidArgumentException');
$image->setImageType('Foo');
}
开发者ID:pfeyssaguet,项目名称:guzzle-aws,代码行数:9,代码来源:ImageTest.php
注:本文中的XMLWriter类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论