本文整理匯總了PHP中XmlWriter::writeCdata方法的典型用法代碼示例。如果您正苦於以下問題:PHP XmlWriter::writeCdata方法的具體用法?PHP XmlWriter::writeCdata怎麽用?PHP XmlWriter::writeCdata使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類XmlWriter
的用法示例。
在下文中一共展示了XmlWriter::writeCdata方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: writeElement
public function writeElement($name, $value, $prefix = null, $url = null)
{
if ($prefix !== null) {
$this->cursor->writeElementNs($prefix, $name, $url, $value);
} elseif ($this->needsCdataWrapping($value)) {
$this->startElement($name, $prefix, $url);
$this->cursor->writeCdata($value);
$this->endElement();
} else {
$this->cursor->writeElement($name, $value);
}
}
示例2: writeValue
public function writeValue($value)
{
if ($this->needsCdataWrapping($value)) {
$this->cursor->writeCdata($value);
} else {
$this->cursor->text($value);
}
}
示例3: toXml
function toXml(XmlWriter $x, $writeEnvelope = true)
{
if ($writeEnvelope) {
$x->startElement('http-request');
}
$x->startElement('method');
$x->text($this->getMethod());
$x->endElement();
$x->startElement('url');
$x->text($this->getUrl());
$x->endElement();
$x->startElement('headers');
foreach ($this->getHeaders() as $k => $v) {
$x->startElement('header');
$x->writeAttribute('name', $k);
$x->text($v);
$x->endElement();
}
$x->endElement();
$x->startElement('params');
foreach ($this->getPostParams() as $k => $v) {
$x->startElement('param');
$x->writeAttribute('name', $k);
$x->text($v);
$x->endElement();
}
$x->endElement();
if (!$this->getPostParams() && $this->getBody()) {
$x->startElement('body');
$x->writeCdata($this->getBody());
$x->endElement();
}
if ($writeEnvelope) {
$x->endElement();
}
}
示例4: writeCategory
private function writeCategory(\XmlWriter $writer, Category $category)
{
$writer->startElement('category');
if ($category->getDomain()) {
$writer->writeAttribute('domain', $category->getDomain());
}
$writer->writeCdata($category->getTitle());
$writer->endElement();
}
示例5: toXml
function toXml(XmlWriter $x)
{
$x->startElement('url');
$x->startElement('method');
$x->text($this->getMethod());
$x->endElement();
$x->startElement('scheme');
$x->text($this->getScheme());
$x->endElement();
$x->startElement('base_url');
$x->text($this->getBaseUrl(true));
$x->endElement();
$x->startElement('path_info');
$x->text($this->getPathInfo());
$x->endElement();
$x->startElement('host');
$x->text($this->getHttpHost());
$x->endElement();
$x->startElement('remote_addr');
$x->text($this->getClientIp(false));
$x->endElement();
$x->endElement();
$x->startElement('params');
foreach ($this->getRequestOnlyParams() as $k => $v) {
$x->startElement('param');
$x->writeAttribute('name', $k);
if (is_array($v) || is_object($v)) {
$v = json_encode($v);
$x->writeAttribute("serialized", "json");
$x->writeCdata($v);
} else {
$x->text($v);
}
$x->endElement();
}
$x->endElement();
}