本文整理汇总了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();
}