本文整理汇总了C++中KoXmlNode::firstChild方法的典型用法代码示例。如果您正苦于以下问题:C++ KoXmlNode::firstChild方法的具体用法?C++ KoXmlNode::firstChild怎么用?C++ KoXmlNode::firstChild使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KoXmlNode
的用法示例。
在下文中一共展示了KoXmlNode::firstChild方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: loadOasisAuthorInfo
bool KoDocumentInfo::loadOasisAuthorInfo(const KoXmlNode &metaDoc)
{
KoXmlElement e = KoXml::namedItemNS(metaDoc, KoXmlNS::dc, "creator");
if (!e.isNull() && !e.text().isEmpty())
setActiveAuthorInfo("creator", e.text());
KoXmlNode n = metaDoc.firstChild();
for (; !n.isNull(); n = n.nextSibling()) {
if (!n.isElement())
continue;
KoXmlElement e = n.toElement();
if (!(e.namespaceURI() == KoXmlNS::meta &&
e.localName() == "user-defined" && !e.text().isEmpty()))
continue;
QString name = e.attributeNS(KoXmlNS::meta, "name", QString());
setActiveAuthorInfo(name, e.text());
}
return true;
}
示例2: buildIndexFromXmlDoc
MetaInfo ZefaniaLex::buildIndexFromXmlDoc(KoXmlDocument *xmldoc)
{
try {
MetaInfo info;
int couldBe = 0;//1 = RMac
Document indexdoc;
const QString index = indexPath();
QString fileTitle;
QString uid;
QString type;
QDir dir("/");
dir.mkpath(index);
RefText refText;
refText.setSettings(m_settings);
IndexWriter* writer = NULL;
const TCHAR* stop_words[] = { NULL };
standard::StandardAnalyzer an(stop_words);
if(IndexReader::indexExists(index.toStdString().c_str())) {
if(IndexReader::isLocked(index.toStdString().c_str())) {
myDebug() << "Index was locked... unlocking it.";
IndexReader::unlock(index.toStdString().c_str());
}
}
writer = new IndexWriter(index.toStdString().c_str() , &an, true);
writer->setMaxFieldLength(0x7FFFFFFFL);
writer->setUseCompoundFile(false);
KoXmlNode item = xmldoc->documentElement().firstChild();
type = xmldoc->documentElement().toElement().attribute("type", "");
for(int c = 0; !item.isNull();) {
QString key = "";
QString title = "";
QString trans = "";
QString pron = "";
QString desc = "";
KoXmlElement e = item.toElement();
if(e.tagName().compare("INFORMATION", Qt::CaseInsensitive) == 0) {
KoXmlNode title = item.namedItem("subject");
KoXmlNode identifer = item.namedItem("identifier");
fileTitle = title.toElement().text();
uid = identifer.toElement().text();
} else if(e.tagName().compare("item", Qt::CaseInsensitive) == 0) {
key = e.attribute("id");
KoXmlNode details = item.firstChild();
while(!details.isNull()) {
KoXmlElement edetails = details.toElement();
if(edetails.tagName().compare("title", Qt::CaseInsensitive) == 0) {
title = edetails.text();
} else if(edetails.tagName().compare("transliteration", Qt::CaseInsensitive) == 0) {
trans = edetails.text();
} else if(edetails.tagName().compare("pronunciation", Qt::CaseInsensitive) == 0) {
KoXmlNode em = details.firstChild();
while(!em.isNull()) {
if(em.toElement().tagName().compare("em", Qt::CaseInsensitive) == 0)
pron = "<em>" + em.toElement().text() + "</em>";
em = em.nextSibling();
}
} else if(edetails.tagName().compare("description", Qt::CaseInsensitive) == 0) {
KoXmlNode descNode = details.firstChild();
while(!descNode.isNull()) {
if(descNode.nodeType() == 2) {
desc += descNode.toText().data();
} else if(descNode.nodeType() == 1) {
KoXmlElement descElement = descNode.toElement();
if(descElement.tagName().compare("reflink", Qt::CaseInsensitive) == 0) {
if(descElement.hasAttribute("mscope")) {
const QString mscope = descElement.attribute("mscope", ";;;");
VerseUrl url;
url.fromMscope(mscope);
desc += " <a href=\"" + url.toString() + "\">" + refText.toString(url) + "</a> ";
} else if(descElement.hasAttribute("target")) {
desc += descElement.text();
}
} else if(descElement.tagName().compare("see", Qt::CaseInsensitive) == 0) {
const QString target = descElement.attribute("target", "");
//todo: currently we assume target = x-self
StrongUrl url;
bool ok = url.fromText(descElement.text());
if(ok)
desc += " <a href=\"" + url.toString() + "\">" + descElement.text() + "</a> ";
}
}
descNode = descNode.nextSibling();
}
desc += "<hr />";
}
//.........这里部分代码省略.........