本文整理匯總了PHP中DomDocument::createTextnode方法的典型用法代碼示例。如果您正苦於以下問題:PHP DomDocument::createTextnode方法的具體用法?PHP DomDocument::createTextnode怎麽用?PHP DomDocument::createTextnode使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類DomDocument
的用法示例。
在下文中一共展示了DomDocument::createTextnode方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: DomDocument
function __doRequest($request, $location, $action, $version)
{
$dom = new DomDocument('1.0', 'UTF-8');
$dom->preserveWhiteSpace = false;
$dom->loadXML($request);
$hdr = $dom->createElement('soapenv:Header');
$secNode = $dom->createElement("wsse:Security");
$secNode->setAttribute("soapenv:mustUnderstand", "1");
$secNode->setAttribute("xmlns:wsse", "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd");
$usernameTokenNode = $dom->createElement("wsse:UsernameToken");
$usernameTokenNode->setAttribute("wsu:Id", "UsernameToken-1");
$usernameTokenNode->setAttribute("xmlns:wsu", "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd");
$usrNode = $dom->createElement("wsse:Username");
$usrNode->appendChild($dom->createTextNode(WS_USER));
$pwdNode = $dom->createElement("wsse:Password");
$pwdNode->setAttribute("Type", "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText");
$pwdNode->appendchild($dom->createTextnode(WS_PWD));
$usernameTokenNode->appendChild($usrNode);
$usernameTokenNode->appendChild($pwdNode);
$secNode->appendChild($usernameTokenNode);
$hdr->appendChild($secNode);
$dom->documentElement->insertBefore($hdr, $dom->documentElement->firstChild);
$request = $dom->saveXML();
$request = str_replace("SOAP-ENV", "soapenv", $request);
$request = str_replace("ns1", "cgt", $request);
$request = str_replace('<?xml version="1.0" encoding="UTF-8"?>', '', $request);
// echo "Este es el nuevo XML: " . print_r($request, true);
return parent::__doRequest($request, $location, $action, $version);
}