本文整理汇总了PHP中XmlWriter::startElementNS方法的典型用法代码示例。如果您正苦于以下问题:PHP XmlWriter::startElementNS方法的具体用法?PHP XmlWriter::startElementNS怎么用?PHP XmlWriter::startElementNS使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XmlWriter
的用法示例。
在下文中一共展示了XmlWriter::startElementNS方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: buildOpenPayUDocument
/**
* Function builds OpenPayU Xml Document
* @access public
* @param string $data
* @param string $start_element
* @param integer $request
* @param string $xml_version
* @param string $xml_encoding
* @return string $xml
*/
public static function buildOpenPayUDocument($data, $start_element, $request = 1, $xml_version = '1.0', $xml_encoding = 'UTF-8')
{
if (!is_array($data)) {
return false;
}
$xml = new XmlWriter();
$xml->openMemory();
$xml->startDocument($xml_version, $xml_encoding);
$xml->startElementNS(null, 'OpenPayU', 'http://www.openpayu.com/openpayu.xsd');
$header = $request == 1 ? 'HeaderRequest' : 'HeaderResponse';
$xml->startElement($header);
$xml->writeElement('Algorithm', 'MD5');
$xml->writeElement('SenderName', 'POSID=' . OpenPayUConfiguration::getMerchantPosid() . ';CUSTOM_PLUGIN=PRESTASHOP');
$xml->writeElement('Version', $xml_version);
$xml->endElement();
// domain level - open
$xml->startElement(OpenPayUDomain::getDomain4Message($start_element));
// message level - open
$xml->startElement($start_element);
self::arr2xml($xml, $data);
// message level - close
$xml->endElement();
// domain level - close
$xml->endElement();
// document level - close
$xml->endElement();
return $xml->outputMemory(true);
}
示例2: serialize
/**
* Serializes given array. The array indices must be string to use them as
* as element name.
*
* @param array $array The object to serialize represented in array.
* @param array $properties The used properties in the serialization process.
*
* @return string
*/
public function serialize($array, $properties = null)
{
$xmlVersion = '1.0';
$xmlEncoding = 'UTF-8';
$standalone = Utilities::tryGetValue($properties, self::STANDALONE);
$defaultTag = Utilities::tryGetValue($properties, self::DEFAULT_TAG);
$rootName = Utilities::tryGetValue($properties, self::ROOT_NAME);
$docNamespace = Utilities::tryGetValue($array, Resources::XTAG_NAMESPACE, null);
if (!is_array($array)) {
return false;
}
$xmlw = new \XmlWriter();
$xmlw->openMemory();
$xmlw->setIndent(true);
$xmlw->startDocument($xmlVersion, $xmlEncoding, $standalone);
if (is_null($docNamespace)) {
$xmlw->startElement($rootName);
} else {
foreach ($docNamespace as $uri => $prefix) {
$xmlw->startElementNS($prefix, $rootName, $uri);
break;
}
}
unset($array[Resources::XTAG_NAMESPACE]);
self::_arr2xml($xmlw, $array, $defaultTag);
$xmlw->endElement();
return $xmlw->outputMemory(true);
}
示例3: outputXml
/**
* Construct the whole DCAT-AP document given an array of dump info
*
* @param array $data data-blob of i18n and config variables
* @return string: xmldata
*/
function outputXml(array $data)
{
// Initializing the XML Object
$xml = new XmlWriter();
$xml->openMemory();
$xml->setIndent(true);
$xml->setIndentString(' ');
// set namespaces
$xml->startDocument('1.0', 'UTF-8');
$xml->startElementNS('rdf', 'RDF', null);
$xml->writeAttributeNS('xmlns', 'rdf', null, 'http://www.w3.org/1999/02/22-rdf-syntax-ns#');
$xml->writeAttributeNS('xmlns', 'dcterms', null, 'http://purl.org/dc/terms/');
$xml->writeAttributeNS('xmlns', 'dcat', null, 'http://www.w3.org/ns/dcat#');
$xml->writeAttributeNS('xmlns', 'foaf', null, 'http://xmlns.com/foaf/0.1/');
$xml->writeAttributeNS('xmlns', 'adms', null, 'http://www.w3.org/ns/adms#');
$xml->writeAttributeNS('xmlns', 'vcard', null, 'http://www.w3.org/2006/vcard/ns#');
// Calls previously declared functions to construct xml
writePublisher($xml, $data);
writeContactPoint($xml, $data);
$dataset = array();
// Live dataset and distributions
$liveDistribs = writeDistribution($xml, $data, 'ld', null);
if ($data['config']['api-enabled']) {
$liveDistribs = array_merge($liveDistribs, writeDistribution($xml, $data, 'api', null));
}
array_push($dataset, writeDataset($xml, $data, null, $liveDistribs));
// Dump dataset and distributions
if ($data['config']['dumps-enabled']) {
foreach ($data['dumps'] as $key => $value) {
$distIds = writeDistribution($xml, $data, 'dump', $key);
array_push($dataset, writeDataset($xml, $data, $key, $distIds));
}
}
writeCatalog($xml, $data, $dataset);
// Closing last XML node
$xml->endElement();
// Printing the XML
return $xml->outputMemory(true);
}
示例4: buildXmlFromArray
/**
* Function builds OpenPayU Xml Document
* @access public
* @param string $data
* @param string $rootElement
* @param string $version
* @param string $encoding
* @param string $rootElementXsi
* @return string $xml
*/
public static function buildXmlFromArray($data, $rootElement, $version = '1.0', $encoding = 'UTF-8', $rootElementXsi = null)
{
if (!is_array($data)) {
return null;
}
$xml = new XmlWriter();
$xml->openMemory();
$xml->setIndent(true);
$xml->startDocument($version, $encoding);
$xml->startElementNS(null, 'OpenPayU', 'http://www.openpayu.com/20/openpayu.xsd');
$xml->startElement($rootElement);
if (!empty($rootElementXsi)) {
$xml->startAttributeNs('xsi', 'type', 'http://www.w3.org/2001/XMLSchema-instance');
$xml->text($rootElementXsi);
$xml->endAttribute();
}
self::convertArrayToXml($xml, $data);
$xml->endElement();
$xml->endElement();
$xml->endDocument();
return trim($xml->outputMemory(true));
}
示例5: buildOpenPayUDocument
/**
* Function builds OpenPayU Xml Document
* @access public
* @param string $data
* @param string $startElement
* @param integer $request
* @param string $xml_version
* @param string $xml_encoding
* @return string $xml
*/
public static function buildOpenPayUDocument($data, $startElement, $request = 1, $xml_version = '1.0', $xml_encoding = 'UTF-8')
{
if (!is_array($data)) {
return false;
}
$xml = new XmlWriter();
$xml->openMemory();
$xml->startDocument($xml_version, $xml_encoding);
if (OpenPayU_Configuration::getApiVersion() < 2) {
$xml->startElementNS(null, 'OpenPayU', 'http://www.openpayu.com/openpayu.xsd');
$header = $request == 1 ? 'HeaderRequest' : 'HeaderResponse';
$xml->startElement($header);
$xml->writeElement('Algorithm', OpenPayU_Configuration::getHashAlgorithm());
$xml->writeElement('SenderName', 'exampleSenderName');
$xml->writeElement('Version', $xml_version);
$xml->endElement();
} else {
$xml->startElementNS(null, 'OpenPayU', 'http://www.openpayu.com/20/openpayu.xsd');
}
// domain level - open
if (OpenPayU_Configuration::getApiVersion() < 2) {
$xml->startElement(OpenPayUDomain::getDomain4Message($startElement));
}
// message level - open
$xml->startElement($startElement);
OpenPayU_Util::convertArrayToXml($xml, $data);
// message level - close
$xml->endElement();
// domain level - close
$xml->endElement();
// document level - close
if (OpenPayU_Configuration::getApiVersion() < 2) {
$xml->endElement();
}
return $xml->outputMemory(true);
}
示例6: _serializeAtom
/**
* Serializes the atom into XML representation.
*
* @param array $properties The atom properties.
*
* @return string
*/
private function _serializeAtom($properties)
{
$xmlw = new \XmlWriter();
$xmlw->openMemory();
$xmlw->setIndent(true);
$xmlw->startDocument(strtoupper($this->_xmlVersion), $this->_xmlEncoding, 'yes');
$xmlw->startElementNS(null, 'entry', $this->_atomNamespaceName);
$xmlw->writeAttribute("xmlns:{$this->_dataServicesPrefix}", $this->_dataServicesNamespaceName);
$xmlw->writeAttribute("xmlns:{$this->_dataServicesMetadataPrefix}", $this->_dataServicesMetadataNamespaceName);
$xmlw->writeElement('title');
$xmlw->writeElement('updated', Utilities::isoDate());
$xmlw->startElement('author');
$xmlw->writeElement('name');
$xmlw->endElement();
$xmlw->writeElement('id');
$xmlw->startElement('content');
$xmlw->writeAttribute('type', Resources::XML_CONTENT_TYPE);
$xmlw->startElementNS($this->_dataServicesMetadataPrefix, 'properties', null);
$this->_generateProperties($xmlw, $properties);
$xmlw->endElement();
$xmlw->endElement();
$xmlw->endElement();
return $xmlw->outputMemory(true);
}