本文整理汇总了C++中NamedNodeMap::setNamedItem方法的典型用法代码示例。如果您正苦于以下问题:C++ NamedNodeMap::setNamedItem方法的具体用法?C++ NamedNodeMap::setNamedItem怎么用?C++ NamedNodeMap::setNamedItem使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NamedNodeMap
的用法示例。
在下文中一共展示了NamedNodeMap::setNamedItem方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: runTest
/*
* Runs the test case.
*/
void runTest()
{
Document doc1;
Document doc2;
NodeList elementList;
Node testAddress;
NamedNodeMap attributes;
Node newAttribute;
String strong;
Node setNode;
doc1 = (Document) baseT::load("hc_staff", true);
doc2 = (Document) baseT::load("hc_staff", true);
elementList = doc1.getElementsByTagName(SA::construct_from_utf8("acronym"));
testAddress = elementList.item(2);
newAttribute = doc2.createAttribute(SA::construct_from_utf8("newAttribute"));
attributes = testAddress.getAttributes();
{
boolean success = false;
try {
setNode = attributes.setNamedItem(newAttribute);
} catch (const DOMException& ex) {
success = (ex.code() == DOMException::WRONG_DOCUMENT_ERR);
}
assertTrue(success);
}
}
示例2: runTest
/*
* Runs the test case.
*/
void runTest()
{
Document doc;
NodeList elementList;
Element firstNode;
Node testNode;
NamedNodeMap attributes;
Attr domesticAttr;
Attr setAttr;
Node setNode;
doc = (Document) baseT::load("staff", true);
elementList = doc.getElementsByTagName(SA::construct_from_utf8("address"));
firstNode = (Element) elementList.item(0);
domesticAttr = doc.createAttribute(SA::construct_from_utf8("domestic"));
domesticAttr.setValue(SA::construct_from_utf8("Yes"));
setAttr = firstNode.setAttributeNode(domesticAttr);
elementList = doc.getElementsByTagName(SA::construct_from_utf8("address"));
testNode = elementList.item(2);
attributes = testNode.getAttributes();
{
boolean success = false;
try {
setNode = attributes.setNamedItem(domesticAttr);
} catch (const DOMException& ex) {
success = (ex.code() == DOMException::INUSE_ATTRIBUTE_ERR);
}
assertTrue(success);
}
}
示例3: setNamedItem
JSValue JSNamedNodeMap::setNamedItem(ExecState* exec, const ArgList& args)
{
NamedNodeMap* imp = static_cast<NamedNodeMap*>(impl());
ExceptionCode ec = 0;
Node* newNode = toNode(args.at(0));
if (newNode && newNode->nodeType() == Node::ATTRIBUTE_NODE && imp->element()) {
if (!allowSettingSrcToJavascriptURL(exec, imp->element(), newNode->nodeName(), newNode->nodeValue()))
return jsNull();
}
JSValue result = toJS(exec, globalObject(), WTF::getPtr(imp->setNamedItem(newNode, ec)));
setDOMException(exec, ec);
return result;
}
示例4: jsNamedNodeMapPrototypeFunctionSetNamedItem
EncodedJSValue JSC_HOST_CALL jsNamedNodeMapPrototypeFunctionSetNamedItem(ExecState* exec)
{
JSValue thisValue = exec->hostThisValue();
if (!thisValue.inherits(&JSNamedNodeMap::s_info))
return throwVMTypeError(exec);
JSNamedNodeMap* castedThis = static_cast<JSNamedNodeMap*>(asObject(thisValue));
NamedNodeMap* imp = static_cast<NamedNodeMap*>(castedThis->impl());
ExceptionCode ec = 0;
Node* node(toNode(exec->argument(0)));
if (exec->hadException())
return JSValue::encode(jsUndefined());
JSC::JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(imp->setNamedItem(node, ec)));
setDOMException(exec, ec);
return JSValue::encode(result);
}