本文整理汇总了C++中QDomNode::toCharacterData方法的典型用法代码示例。如果您正苦于以下问题:C++ QDomNode::toCharacterData方法的具体用法?C++ QDomNode::toCharacterData怎么用?C++ QDomNode::toCharacterData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QDomNode
的用法示例。
在下文中一共展示了QDomNode::toCharacterData方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: writeElementChilds
void FileWriter::writeElementChilds(const QDomElement &AParent)
{
QDomNode node = AParent.firstChild();
while (!node.isNull())
{
if (node.isElement())
{
QDomElement elem = node.toElement();
if (elem.tagName() != "thread")
{
FXmlWriter->writeStartElement(elem.tagName());
QString elemNs = elem.namespaceURI();
if (!elemNs.isEmpty() && elem.parentNode().namespaceURI()!=elemNs)
FXmlWriter->writeAttribute("xmlns",elem.namespaceURI());
QDomNamedNodeMap attrMap = elem.attributes();
for (uint i=0; i<attrMap.length(); i++)
{
QDomNode attrNode = attrMap.item(i);
FXmlWriter->writeAttribute(attrNode.nodeName(), attrNode.nodeValue());
}
writeElementChilds(elem);
FXmlWriter->writeEndElement();
}
}
else if (node.isCharacterData())
{
FXmlWriter->writeCharacters(node.toCharacterData().data());
}
node = node.nextSibling();
}
}
示例2: QDomCharacterData
QDomCharacterData QDomNodeProto:: toCharacterData() const
{
QDomNode *item = qscriptvalue_cast<QDomNode*>(thisObject());
if (item)
return item->toCharacterData();
return QDomCharacterData();
}
示例3: innerXml
QString XMLWork::innerXml(QDomElement &element)
{
QString inner;
for (QDomNode n = element.firstChild(); !n.isNull(); n = n.nextSibling())
if (n.isCharacterData())
inner += n.toCharacterData().data();
else if (n.isElement()) {
QDomElement e = n.toElement();
inner += "<" + e.tagName() + ">" + innerXml(e) + "</" + e.tagName() + ">";
}
return inner;
}
示例4: changeDomElementContents
bool changeDomElementContents(const QDomElement &element,
Predicate p,
const QString &newValue,
QString *ptrToOldValue = 0)
{
// Find text in "<element>text</element>"
const QDomNodeList children = element.childNodes();
if (children.size() != 1)
return false;
const QDomNode first = children.at(0);
if (first.nodeType() != QDomNode::TextNode)
return false;
QDomCharacterData data = first.toCharacterData();
const QString oldValue = data.data();
if (p(oldValue)) {
if (ptrToOldValue)
*ptrToOldValue = oldValue;
data.setData(newValue);
return true;
}
return false;
}