本文整理汇总了PHP中XMLCustomWriter::createTextNode方法的典型用法代码示例。如果您正苦于以下问题:PHP XMLCustomWriter::createTextNode方法的具体用法?PHP XMLCustomWriter::createTextNode怎么用?PHP XMLCustomWriter::createTextNode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XMLCustomWriter
的用法示例。
在下文中一共展示了XMLCustomWriter::createTextNode方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1:
function &createChildWithText(&$doc, &$node, $name, $value, $appendIfEmpty = true)
{
$childNode = null;
if ($appendIfEmpty || $value != '') {
$childNode =& XMLCustomWriter::createElement($doc, $name);
$textNode =& XMLCustomWriter::createTextNode($doc, $value);
XMLCustomWriter::appendChild($childNode, $textNode);
XMLCustomWriter::appendChild($node, $childNode);
}
return $childNode;
}
示例2: explode
/**
* Create a new XML node.
* @param $doc XMLNode|DOMImplementation
* @param $nodePath string an XPath-like string that describes the
* node to be created.
* @param $value string the value to be added as a text node (if any)
* @return XMLNode|DOMDocument
*/
function &_createNode($doc, $nodePath, $value = null)
{
// Separate the element name from the attributes.
$elementPlusAttributes = explode('[', $nodePath);
$element = $elementPlusAttributes[0];
assert(!empty($element));
// Create the element.
$newNode =& XMLCustomWriter::createElement($doc, $element);
// Add attributes.
if (count($elementPlusAttributes) == 2) {
// Separate the attribute key/value pairs.
$unparsedAttributes = explode('@', rtrim(ltrim($elementPlusAttributes[1], '@'), ']'));
foreach ($unparsedAttributes as $unparsedAttribute) {
// Split attribute expressions into key and value.
list($attributeName, $attributeValue) = explode('=', rtrim($unparsedAttribute, ' '));
$attributeValue = trim($attributeValue, '"');
XMLCustomWriter::setAttribute($newNode, $attributeName, $attributeValue);
}
}
// Insert a text node if we got a value for it.
if (!is_null($value)) {
$textNode =& XMLCustomWriter::createTextNode($doc, $value);
XMLCustomWriter::appendChild($newNode, $textNode);
}
return $newNode;
}
示例3: foreach
/**
* Generate doi_data element - this is what assigns the DOI
* @param $doc XMLNode
* @param $DOI string
* @param $url string
* @param $galleys array
*/
function &_generateDOIdataDom(&$doc, $DOI, $url, $galleys = null)
{
$request = Application::getRequest();
$journal = $request->getJournal();
$DOIdataNode =& XMLCustomWriter::createElement($doc, 'doi_data');
XMLCustomWriter::createChildWithText($doc, $DOIdataNode, 'doi', $DOI);
XMLCustomWriter::createChildWithText($doc, $DOIdataNode, 'resource', $url);
/* article galleys */
if ($galleys) {
$collectionNode = XMLCustomWriter::createElement($doc, 'collection');
XMLCustomWriter::setAttribute($collectionNode, 'property', 'text-mining');
XMLCustomWriter::appendChild($DOIdataNode, $collectionNode);
foreach ($galleys as $galley) {
$itemNode = XMLCustomWriter::createElement($doc, 'item');
XMLCustomWriter::appendChild($collectionNode, $itemNode);
$resourceNode = XMLCustomWriter::createElement($doc, 'resource');
XMLCustomWriter::appendChild($itemNode, $resourceNode);
XMLCustomWriter::setAttribute($resourceNode, 'mime_type', $galley->getFileType());
$urlNode = XMLCustomWriter::createTextNode($doc, $request->url(null, 'article', 'viewFile', array($galley->getArticleId(), $galley->getBestGalleyId($journal))));
XMLCustomWriter::appendChild($resourceNode, $urlNode);
}
}
return $DOIdataNode;
}
示例4: array
/**
* Create an XML element with a text node.
*
* FIXME: Move this to XMLCustomWriter? I leave the decision up to PKP...
*
* @param $name string
* @param $value string
* @param $attributes array An array with the attribute names as array
* keys and attribute values as array values.
*
* @return XMLNode|DOMImplementation
*/
function &createElementWithText($name, $value, $attributes = array())
{
$element =& XMLCustomWriter::createElement($this->getDoc(), $name);
$elementContent =& XMLCustomWriter::createTextNode($this->getDoc(), String::html2text($value));
XMLCustomWriter::appendChild($element, $elementContent);
foreach ($attributes as $attributeName => $attributeValue) {
XMLCustomWriter::setAttribute($element, $attributeName, $attributeValue);
}
return $element;
}
示例5: explode
/**
* Create a new XML node.
* @param $doc XMLNode|DOMImplementation
* @param $nodePath string an XPath-like string that describes the
* node to be created.
* @param $value string the value to be added as a text node (if any)
* @return XMLNode|DOMDocument
*/
function &_createNode($doc, $nodePath, $value = null)
{
// Separate the element name from the attributes.
$elementPlusAttributes = explode('[', $nodePath);
$element = $elementPlusAttributes[0];
assert(!empty($element));
// Create the element.
$newNode =& XMLCustomWriter::createElement($doc, $element);
// Check for configurable attributes in element value, remove them from value
// and add them to regular attributes
$attributeOffset = strpos($value, '[@');
if ($attributeOffset !== false) {
// no configurable attributes
if (count($elementPlusAttributes) < 2) {
$elementPlusAttributes[] = '';
}
if ($attributeOffset !== 0) {
$elementPlusAttributes[1] = rtrim($elementPlusAttributes[1], ']') . ltrim(substr($value, $attributeOffset), '[');
$value = substr($value, 0, $attributeOffset);
} else {
$elementPlusAttributes[1] = rtrim($elementPlusAttributes[1], ']') . ltrim(substr($value, $attributeOffset), '[');
$value = "";
}
}
// Add attributes.
if (count($elementPlusAttributes) == 2) {
// Separate the attribute key/value pairs.
$unparsedAttributes = explode('@', rtrim(ltrim($elementPlusAttributes[1], '@'), ']'));
foreach ($unparsedAttributes as $unparsedAttribute) {
// Split attribute expressions into key and value.
list($attributeName, $attributeValue) = explode('=', rtrim($unparsedAttribute, ' '));
$attributeValue = trim($attributeValue, '"');
XMLCustomWriter::setAttribute($newNode, $attributeName, $attributeValue);
}
}
// Insert a text node if we got a value for it.
if (!is_null($value)) {
$textNode =& XMLCustomWriter::createTextNode($doc, $value);
XMLCustomWriter::appendChild($newNode, $textNode);
}
return $newNode;
}