本文整理汇总了C++中Attr::appendChild方法的典型用法代码示例。如果您正苦于以下问题:C++ Attr::appendChild方法的具体用法?C++ Attr::appendChild怎么用?C++ Attr::appendChild使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Attr
的用法示例。
在下文中一共展示了Attr::appendChild方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: runTest
/*
* Runs the test case.
*/
void runTest()
{
Document doc;
NodeList acronymList;
Node testNode;
NamedNodeMap attributes;
Attr titleAttr;
String value;
Text textNode;
Node retval;
Node lastChild;
doc = (Document) baseT::load("hc_staff", true);
titleAttr = doc.createAttribute(SA::construct_from_utf8("title"));
textNode = doc.createTextNode(SA::construct_from_utf8("Yesterday"));
retval = titleAttr.appendChild(textNode);
value = titleAttr.getValue();
baseT::assertEquals("Yesterday", value, __LINE__, __FILE__);
value = titleAttr.getNodeValue();
baseT::assertEquals("Yesterday", value, __LINE__, __FILE__);
value = retval.getNodeValue();
baseT::assertEquals("Yesterday", value, __LINE__, __FILE__);
lastChild = titleAttr.getLastChild();
value = lastChild.getNodeValue();
baseT::assertEquals("Yesterday", value, __LINE__, __FILE__);
}
示例2: runTest
/*
* Runs the test case.
*/
void runTest()
{
Document doc;
NodeList acronymList;
Node testNode;
NamedNodeMap attributes;
Attr titleAttr;
String value;
Node textNode;
Node retval;
Node lastChild;
Document otherDoc;
doc = (Document) baseT::load("hc_staff", true);
otherDoc = (Document) baseT::load("hc_staff", true);
acronymList = doc.getElementsByTagName(SA::construct_from_utf8("acronym"));
testNode = acronymList.item(3);
attributes = testNode.getAttributes();
titleAttr = (Attr) attributes.getNamedItem(SA::construct_from_utf8("title"));
textNode = otherDoc.createTextNode(SA::construct_from_utf8("terday"));
{
boolean success = false;
try {
retval = titleAttr.appendChild(textNode);
} catch (const DOMException& ex) {
success = (ex.code() == DOMException::WRONG_DOCUMENT_ERR);
}
assertTrue(success);
}
}
示例3: cloneNodeExport
Node* Attr::cloneNodeExport(Document* ownerDocument, bool deep) const
{
Attr* pNewAttr = new Attr;
pNewAttr->m_ownerDocument = ownerDocument;
pNewAttr->m_nodeName = m_nodeName;
pNewAttr->m_prefix = m_prefix;
pNewAttr->m_localName = m_localName;
pNewAttr->m_namespaceURI = m_namespaceURI;
// TODO: specified
// Clone children (regardless of deep since we're an attribute (?))
for (unsigned int i = 0; i < m_childNodes->m_items.GetSize(); i++)
{
Node* node = m_childNodes->m_items[i]->cloneNodeExport(ownerDocument, true);
pNewAttr->appendChild(node);
}
return pNewAttr;
}