本文整理汇总了PHP中XMLWriter::writeRaw方法的典型用法代码示例。如果您正苦于以下问题:PHP XMLWriter::writeRaw方法的具体用法?PHP XMLWriter::writeRaw怎么用?PHP XMLWriter::writeRaw使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XMLWriter
的用法示例。
在下文中一共展示了XMLWriter::writeRaw方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: serialize
/**
* @param array $ticket
* @return string
*/
public function serialize($ticket)
{
$this->buffer->writeRaw('<?xml version="1.0" encoding="utf-8"?>');
$this->buffer->startElement('ticket');
$this->generateTicket($ticket);
$this->buffer->endElement();
return $this->buffer->outputMemory();
}
示例2: GetProjectDetail
function GetProjectDetail($projId)
{
//Return metadata about the columns in each table for a given database (table_schema)
$qry = "SELECT id, p_name, p_details FROM tb_projects where id = " . $projId;
date_default_timezone_set('Australia/Sydney');
error_log("In project_get_detail.php...\n" . $qry);
$dbConn = opendatabase();
$result = mysqli_query($dbConn, $qry);
date_default_timezone_set('Australia/Sydney');
error_log("Records in Projects: " . mysqli_num_rows($result));
if (!$result || mysqli_num_rows($result) <= 0) {
echo "Could not obtain metadata information.";
return false;
}
/*****************************************************************/
$xml = new XMLWriter();
//$projXml = new DOMDocument();
//$xml->openURI("php://output");
$xml->openMemory();
$xml->startDocument();
$xml->setIndent(true);
$xml->startElement("projects");
while ($row = mysqli_fetch_assoc($result)) {
$xml->startElement("project");
$xml->writeAttribute('id', $projId);
$xml->writeRaw($row['p_name']);
$xml->endElement();
$xml->startElement("project_details");
$xml->startCData("details");
$xml->writeRaw($row['p_details']);
$xml->endCData();
$xml->endElement();
}
$xml->endElement();
$xml->endDocument();
$dbConn->close();
header('Content-type: text/xml');
$strXML = $xml->outputMemory(TRUE);
$xml->flush();
date_default_timezone_set('Australia/Sydney');
error_log("String XML:\n " . $strXML);
//$projXml->loadXML($strXML);
echo $strXML;
/*****************************************************************
$options = array();
while ($row = mysqli_fetch_assoc($result)){
$options['object_row'][] = $row;
}
echo json_encode($options);
*****************************************************************/
}
示例3: Encode
public static function Encode($requestObject)
{
$soap = "";
try {
$writer = new XMLWriter();
$writer->openMemory();
$writer->startDocument();
$writer->setIndent(4);
$writer->startElement("soap:Envelope");
$writer->writeAttribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance");
$writer->writeAttribute("xmlns:xsd", "http://www.w3.org/2001/XMLSchema");
$writer->writeAttribute("xmlns:soap", "http://schemas.xmlsoap.org/soap/envelope/");
$writer->startElement("soap:Body");
$options = array(XML_SERIALIZER_OPTION_INDENT => ' ', XML_SERIALIZER_OPTION_LINEBREAKS => "\n", XML_SERIALIZER_OPTION_DEFAULT_TAG => '', XML_SERIALIZER_OPTION_TYPEHINTS => false, XML_SERIALIZER_OPTION_IGNORE_NULL => true, XML_SERIALIZER_OPTION_CLASSNAME_AS_TAGNAME => true);
$serializer = new XML_Serializer($options);
$result = $serializer->serialize($requestObject);
if ($result === true) {
$xml = $serializer->getSerializedData();
$xml = str_replace('<>', '', $xml);
$xml = str_replace('</>', '', $xml);
}
$writer->writeRaw($xml);
$writer->endElement();
$writer->endElement();
$writer->endDocument();
$soap = $writer->flush();
$soap = str_replace("<?xml version=\"1.0\"?>", "", $soap);
} catch (Exception $ex) {
throw new Exception("Error occurred while Soap encoding");
}
return $soap;
}
示例4: to_html
public function to_html($parent)
{
$w = new XMLWriter();
$w->openMemory();
$w->startElement('div');
$w->writeAttribute('class', 'season');
$w->startElement('div');
$w->writeAttribute('class', 'season_name');
$w->text("Saison " . $this->get_num());
$w->endElement();
$w->startElement('div');
$w->writeAttribute('class', 'episode_container');
$str = "";
usort($this->episodes, 'wssub_cmp_num');
foreach ($this->episodes as $ep) {
if (!$ep->get_num()) {
$this->log("Bad ep with no number: " . $ep->to_string(), 'warn');
continue;
}
$str .= $ep->to_html($parent);
}
$w->writeRaw($str);
$w->endElement();
$w->endElement();
return $w->flush();
}
示例5: writeRaw
/**
* Fallback method for writeRaw, introduced in PHP 5.2
*
* @param string $text
* @return string
*/
public function writeRaw($text)
{
if (isset($this->_xmlWriter) && is_object($this->_xmlWriter) && method_exists($this->_xmlWriter, 'writeRaw')) {
return $this->_xmlWriter->writeRaw($text);
}
return $this->text($text);
}
示例6: handleElement
/**
* Method for parsing of elements
*
* @param string $node - node name
* @param string $item - node content
* @param bool $wrap - should be wrapped in array for singularization
*
* @return void
*
* @since 1.0
*/
protected function handleElement($node, $item, $wrap = true)
{
if ($this->dispatcher->listensTo($node)) {
$this->dispatcher->trigger($node, array($this->writer, $node, $item));
} else {
if ($node === self::COMMENT) {
if (!is_array($item)) {
$item = array($item);
}
foreach ($item as $comment) {
$this->writer->writeComment($comment);
}
} elseif ($node === self::CDATA) {
$this->writer->writeCdata($item);
} else {
if ($wrap === true) {
if ($this->assertElementName($node)) {
if ($this->config->nil_on_null === true && is_null($item)) {
$this->writer->startElement($node);
$this->writer->writeAttribute('xsi:nil', 'true');
$this->writer->writeRaw($item);
$this->writer->endElement();
} else {
$this->writer->writeElement($node, $item);
}
}
} else {
$this->writer->writeRaw($item);
}
}
}
}
示例7: _genResponse
protected function _genResponse()
{
$writer = new \XMLWriter();
$writer->setIndent(4);
$writer->openMemory();
$writer->startElement('Response');
foreach ($this->getMessages() as $message) {
$writer->startElement('Sms');
$writer->writeRaw((string) $message);
$writer->endElement();
}
if ($redirect = $this->getRedirect()) {
$writer->startElement('Redirect');
$writer->writeRaw($redirect);
$writer->endElement();
}
$writer->endElement();
return $writer->outputMemory(true);
}
示例8: write
public function write(\XMLWriter $writer, \DateTimeZone $timezone, $stringTag)
{
$xml = $this->value->asXML();
// Not all combinations of PHP/libxml support stripping
// the XML declaration. So, we do it ourselves here.
if (strlen($xml) >= 6 && !strncmp($xml, '<?xml', 5) && strpos(" \t\r\n", $xml[5]) !== false) {
$xml = (string) substr($xml, strpos($xml, '?>') + 2);
}
$writer->startElementNS('ex', 'dom', 'http://ws.apache.org/xmlrpc/namespaces/extensions');
$writer->writeRaw($xml);
$writer->fullEndElement();
}
示例9: to_html
public function to_html($parent)
{
$w = new XMLWriter();
$w->openMemory();
$w->startElement('div');
$w->writeAttribute('class', 'log_message');
$w->startElement('div');
$w->writeAttribute('class', 'log_message_' . $this->type);
$w->writeRaw('<div class="log_class">' . $this->class . '</div>::<div class="log_msg">' . $this->msg . '</div>');
$w->endElement();
$w->endElement();
return $w->flush();
}
示例10: generate
/**
* Generates the export
*
* @param integer $categoryId Category Id
* @param boolean $downwards If true, downwards, otherwise upward ordering
* @param string $language Language
*
* @return string
*/
public function generate($categoryId = 0, $downwards = true, $language = '')
{
global $PMF_LANG;
// Initialize categories
$this->category->transform($categoryId);
$faqdata = $this->faq->get(FAQ_QUERY_TYPE_EXPORT_XHTML, $categoryId, $downwards, $language);
$version = PMF_Configuration::getInstance()->get('main.currentVersion');
$comment = sprintf('XHTML output by phpMyFAQ %s | Date: %s', $version, PMF_Date::createIsoDate(date("YmdHis")));
$this->xml->startDocument('1.0', 'utf-8');
$this->xml->writeDtd('html', '-//W3C//DTD XHTML 1.0 Transitional//EN', 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd');
$this->xml->startElement('html');
$this->xml->writeAttribute('xmlns', 'http://www.w3.org/1999/xhtml');
$this->xml->writeAttribute('xml:lang', $language);
$this->xml->writeComment($comment);
$this->xml->startElement('head');
$this->xml->writeElement('title', PMF_Configuration::getInstance()->get('main.titleFAQ'));
$this->xml->startElement('meta');
$this->xml->writeAttribute('http-equiv', 'Content-Type');
$this->xml->writeAttribute('content', 'application/xhtml+xml; charset=utf-8');
$this->xml->endElement();
$this->xml->endElement();
// </head>
$this->xml->startElement('body');
$this->xml->writeAttribute('dir', $PMF_LANG['dir']);
if (count($faqdata)) {
$lastCategory = 0;
foreach ($faqdata as $data) {
if ($data['category_id'] != $lastCategory) {
$this->xml->writeElement('h1', $this->category->getPath($data['category_id'], ' >> '));
}
$this->xml->writeElement('h2', strip_tags($data['topic']));
$this->xml->startElement('p');
$this->xml->writeRaw(html_entity_decode($data['content'], ENT_QUOTES, 'UTF-8'));
$this->xml->endElement();
$this->xml->writeElement('p', $PMF_LANG['msgAuthor'] . ': ' . $data['author_email']);
$this->xml->writeElement('p', $PMF_LANG['msgLastUpdateArticle'] . PMF_Date::createIsoDate($data['lastmodified']));
$lastCategory = $data['category_id'];
}
}
$this->xml->endElement();
// </body>
$this->xml->endElement();
// </html>
header('Content-type: text/html');
return $this->xml->outputMemory();
}
示例11: addToken
private function addToken(array $token)
{
if ($this->lastLine < $token['line']) {
$this->writer->endElement();
for ($t = $this->lastLine + 1; $t < $token['line']; $t++) {
$this->writer->startElement('line');
$this->writer->writeAttribute('no', $t);
$this->writer->endElement();
}
$this->writer->startElement('line');
$this->writer->writeAttribute('no', $token['line']);
$this->lastLine = $token['line'];
}
if ($token['value'] != '') {
$this->writer->startElement('token');
$this->writer->writeAttribute('name', $token['name']);
$this->writer->writeRaw(htmlspecialchars($token['value'], ENT_NOQUOTES | ENT_DISALLOWED | ENT_XML1));
$this->writer->endElement();
}
}
示例12: addToken
private function addToken(array $token)
{
if ($this->lastLine < $token['line']) {
$this->writer->endElement();
for ($t = $this->lastLine + 1; $t < $token['line']; $t++) {
$this->writer->startElement('line');
$this->writer->writeAttribute('no', $t);
$this->writer->endElement();
}
$this->writer->startElement('line');
$this->writer->writeAttribute('no', $token['line']);
$this->lastLine = $token['line'];
}
if ($token['value'] != '') {
$this->writer->startElement('token');
$this->writer->writeAttribute('name', $token['name']);
$this->writer->writeRaw($this->encodeString($token['value']));
$this->writer->endElement();
}
}
示例13: asXML
public function asXML()
{
$w = new \XMLWriter();
$w->openMemory();
$w->startDocument();
$w->startElement('xml');
foreach ($this->data as $one) {
if ($one[2]) {
$w->startElement($one[0]);
$w->writeRaw($one[1]);
$w->endElement();
} else {
$w->writeElement($one[0], $one[1]);
}
}
$w->endElement();
$w->endDocument();
$this->data = [];
// 清空, 以备下次使用
return $w->outputMemory();
}
示例14: writeScalar
/**
* @param \XMLWriter $writer
* @param mixed $origin
* @param Definition $definition
*/
protected function writeScalar(\XMLWriter $writer, $origin, Definition $definition)
{
$content = $definition->extract($origin);
if (strpbrk($content, '></&![]\\') === false) {
$writer->writeRaw($content);
} else {
$writer->writeCdata($content);
}
}
示例15: die
<?php
include_once "config.php";
$sql = "select * from posts";
$res = $con->query($sql) or die("Error Json Api 1");
$xml = new XMLWriter();
$xml->openURI("php://output");
$xml->startDocument();
$xml->setIndent(true);
$xml->startElement('Posts');
while ($row = $res->fetch_assoc()) {
$xml->startElement("Post");
$xml->startElement("title");
$xml->writeRaw($row['title']);
$xml->endElement();
$xml->startElement("description");
$xml->writeRaw($row['description']);
$xml->endElement();
$xml->startElement("user_id");
$xml->writeRaw($row['user_id']);
$xml->endElement();
$xml->endElement();
}
$xml->endElement();
header('Content-type: text/xml');
$xml->flush();
$con->close();