コード例 #1
0
 public function Voice($MediaId)
 {
     $w = new \XMLWriter();
     $w->openMemory();
     $w->writeElement('MediaId', $MediaId);
     $this->add('Voice', $w->outputMemory(), true);
 }
コード例 #2
0
 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);
         }
     }
 }
コード例 #3
0
ファイル: MiscTest.php プロジェクト: georgeh/php-beerxml
 public function testAmountIsWeightIsOmmittedIfFalse()
 {
     $this->record->setAmountIsWeight(false);
     $this->gen->build();
     $xml = $this->xmlWriter->outputMemory(true);
     $this->assertNotTag(array('tag' => 'AMOUNT_IS_WEIGHT'), $xml, '', false);
 }
コード例 #4
0
 /**
  * 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);
             }
         }
     }
 }
コード例 #5
0
ファイル: PlatformWriter.php プロジェクト: refinery29/sitemap
 public function write(PlatformInterface $platform, \XMLWriter $xmlWriter)
 {
     $xmlWriter->startElement('video:platform');
     $xmlWriter->writeAttribute('relationship', $platform->relationship());
     $xmlWriter->text(implode(' ', $platform->types()));
     $xmlWriter->endElement();
 }
コード例 #6
0
ファイル: Xml.php プロジェクト: SandeepUmredkar/PortalSMIP
 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>');
 }
コード例 #7
0
ファイル: Xml.php プロジェクト: dafik/dfi
 /**
  * @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 . "");
         }
     }
 }
コード例 #8
0
 public function write(RestrictionInterface $restriction, \XMLWriter $xmlWriter)
 {
     $xmlWriter->startElement('video:restriction');
     $xmlWriter->writeAttribute('relationship', $restriction->relationship());
     $xmlWriter->text(implode(' ', $restriction->countryCodes()));
     $xmlWriter->endElement();
 }
コード例 #9
0
ファイル: UrlSetWriter.php プロジェクト: refinery29/sitemap
 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);
 }
コード例 #10
0
 /**
  * Close current writer and flush if needed.
  *
  * @return void
  */
 public function close()
 {
     if ($this->xmlWriter) {
         $this->xmlWriter->flush();
     }
     $this->xmlWriter = null;
 }
コード例 #11
0
 protected function getItem()
 {
     $xml = new \XMLWriter();
     $xml->openMemory();
     $xml->setIndent(true);
     $item = new Price($xml);
     return $item;
 }
コード例 #12
0
 /**
  * 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;
 }
コード例 #13
0
ファイル: AddressTest.php プロジェクト: lucasmro/clearsale
 private function generateXML(XmlEntityInterface $xmlEntity)
 {
     $xmlWriter = new \XMLWriter();
     $xmlWriter->openMemory();
     $xmlWriter->setIndent(false);
     $xmlEntity->toXML($xmlWriter);
     return $xmlWriter->outputMemory(true);
 }
コード例 #14
0
 public function finalize()
 {
     $this->writer->endElement();
     $fragment = $this->contextNode->ownerDocument->createDocumentFragment();
     $fragment->appendXML($this->writer->outputMemory());
     $this->contextNode->parentNode->replaceChild($fragment, $this->contextNode);
     $this->finalized = true;
 }
コード例 #15
0
 public function finalize()
 {
     $this->xml->endElement();
     //root element
     $this->xml->endDocument();
     $this->xml->flush();
     return $this->filename;
 }
コード例 #16
0
ファイル: Document.php プロジェクト: maximfisyuk/price-writer
 public function end()
 {
     if (!$this->documentEnded) {
         $this->xmlWriter->endDocument();
         $this->xmlWriter->flush();
         $this->documentEnded = true;
     }
 }
コード例 #17
0
 public function writeXML(\XMLWriter $xmlWriter)
 {
     if ($this->mailAttributes != NULL) {
         $xmlWriter->startELement(Constants::MESSAGE_ATTRIBUTES);
         $this->mailAttributes->writeXML($xmlWriter);
         $xmlWriter->endElement();
     }
 }
コード例 #18
0
ファイル: StringType.php プロジェクト: fpoirotte/xrl
 public function write(\XMLWriter $writer, \DateTimeZone $timezone, $stringTag)
 {
     if ($stringTag) {
         $writer->writeElement('string', $this->value);
     } else {
         $writer->text($this->value);
     }
 }
コード例 #19
0
 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();
 }
コード例 #20
0
 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);
     }
 }
コード例 #21
0
 public function testSetCarrierCode()
 {
     $xml = new \XMLWriter();
     $xml->openMemory();
     $xml->setIndent(true);
     $f = new OrderFulfillment($xml);
     $this->setExpectedException('InvalidArgumentException');
     $f->setCarrierCode('Foo');
 }
コード例 #22
0
ファイル: SitemapWriter.php プロジェクト: refinery29/sitemap
 private function writeLastModified(\XMLWriter $xmlWriter, \DateTimeInterface $lastModified = null)
 {
     if ($lastModified === null) {
         return;
     }
     $xmlWriter->startElement('lastmod');
     $xmlWriter->text($lastModified->format('c'));
     $xmlWriter->endElement();
 }
コード例 #23
0
 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();
 }
コード例 #24
0
ファイル: AbstractInteger.php プロジェクト: fpoirotte/xrl
 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));
 }
コード例 #25
0
ファイル: ImageTest.php プロジェクト: pfeyssaguet/guzzle-aws
 public function testSetImageType()
 {
     $xml = new \XMLWriter();
     $xml->openMemory();
     $xml->setIndent(true);
     $image = new Image($xml);
     $this->setExpectedException('InvalidArgumentException');
     $image->setImageType('Foo');
 }
コード例 #26
0
 public function writeMessagePropertiesForPublishXML(\XMLWriter $xmlWriter)
 {
     if ($this->messageBody != NULL) {
         $xmlWriter->writeElement(Constants::MESSAGE_BODY, $this->messageBody);
     }
     if ($this->messageAttributes !== NULL) {
         $this->messageAttributes->writeXML($xmlWriter);
     }
 }
コード例 #27
0
ファイル: ImageWriter.php プロジェクト: refinery29/sitemap
 private function writeLicence(\XMLWriter $xmlWriter, $licence = null)
 {
     if ($licence === null) {
         return;
     }
     $xmlWriter->startElement('image:licence');
     $xmlWriter->text($licence);
     $xmlWriter->endElement();
 }
コード例 #28
0
ファイル: UploaderWriter.php プロジェクト: refinery29/sitemap
 public function write(UploaderInterface $uploader, \XMLWriter $xmlWriter)
 {
     $xmlWriter->startElement('video:uploader');
     if ($uploader->info() !== null) {
         $xmlWriter->writeAttribute('info', $uploader->info());
     }
     $xmlWriter->text($uploader->name());
     $xmlWriter->endElement();
 }
コード例 #29
0
ファイル: NewsWriter.php プロジェクト: refinery29/sitemap
 private function writeStockTickers(\XMLWriter $xmlWriter, array $stockTickers)
 {
     if (count($stockTickers) === 0) {
         return;
     }
     $xmlWriter->startElement('news:stock_tickers');
     $xmlWriter->text(implode(', ', $stockTickers));
     $xmlWriter->endElement();
 }
コード例 #30
0
 public function write(GalleryLocationInterface $galleryLocation, \XMLWriter $xmlWriter)
 {
     $xmlWriter->startElement('video:gallery_loc');
     if ($galleryLocation->title()) {
         $xmlWriter->writeAttribute('title', $galleryLocation->title());
     }
     $xmlWriter->text($galleryLocation->location());
     $xmlWriter->endElement();
 }