本文整理汇总了C++中dom::Node::childNodes方法的典型用法代码示例。如果您正苦于以下问题:C++ Node::childNodes方法的具体用法?C++ Node::childNodes怎么用?C++ Node::childNodes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dom::Node
的用法示例。
在下文中一共展示了Node::childNodes方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: extractAddress
static QString extractAddress(DOM::Node node) {
QString rc = ";;";
QMap<QString,QString> entry;
DOM::NodeList nodes = node.childNodes();
unsigned int n = nodes.length();
for (unsigned int i = 0; i < n; ++i) {
DOM::Node node = nodes.item(i);
DOM::NamedNodeMap map = node.attributes();
for (unsigned int j = 0; j < map.length(); ++j) {
if (map.item(j).nodeName().string() != "class") {
continue;
}
QString a = map.item(j).nodeValue().string();
if (a == "street-address") {
entry["street-address"] = textForNode(node);
} else if (a == "locality") {
entry["locality"] = textForNode(node);
} else if (a == "region") {
entry["region"] = textForNode(node);
} else if (a == "postal-code") {
entry["postal-code"] = textForNode(node);
}
}
}
rc += entry["street-address"] + ";" + entry["locality"] + ";" + entry["region"] + ";" + entry["postal-code"] + ";" + entry["country"];
return rc.stripWhiteSpace();
}
示例2: hasMicroFormat
bool KonqMFIcon::hasMicroFormat(DOM::NodeList nodes) {
bool ok = false;
unsigned int n = nodes.length();
for (unsigned int i = 0; i < n; ++i) {
DOM::Node node = nodes.item(i);
DOM::NamedNodeMap map = node.attributes();
for (unsigned int j = 0; j < map.length(); ++j) {
if (map.item(j).nodeName().string() != "class") {
continue;
}
if (map.item(j).nodeValue().string() == "vevent") {
ok = true;
extractEvent(node);
break;
}
if (map.item(j).nodeValue().string() == "vcard") {
ok = true;
extractCard(node);
break;
}
}
if (hasMicroFormat(node.childNodes())) {
ok = true;
}
}
return ok;
}
示例3: deLinkify
QString ResultsView::deLinkify( DOM::Node node )
{
//TODO: make this function more flexible (ie, accept non-link-content as
//well.)
QString word;
for ( int i = 0; i < node.childNodes().length(); ++i )
{
if ( node.childNodes().item(i).nodeName() != "a" )
{
return QString();
}
if ( ! node.childNodes().item(i).hasChildNodes() )
{
return QString();
}
word += node.childNodes().item(i).childNodes().item( 0 ).nodeValue().string();
}
return word;
}
示例4: textForNode
static QString textForNode(DOM::Node node) {
QString rc;
DOM::NodeList nl = node.childNodes();
for (unsigned int i = 0; i < nl.length(); ++i) {
DOM::Node n = nl.item(i);
if (n.nodeType() == DOM::Node::TEXT_NODE) {
rc += n.nodeValue().string();
}
}
// FIXME: entries need to be escaped for vcard/vevent
return rc.stripWhiteSpace();
}
示例5: extractCard
void KonqMFIcon::extractCard(DOM::Node node) {
QString name, value;
DOM::NodeList nodes = node.childNodes();
unsigned int n = nodes.length();
value += "BEGIN:VCARD\nVERSION:3.0\n";
for (unsigned int i = 0; i < n; ++i) {
DOM::Node node = nodes.item(i);
DOM::NamedNodeMap map = node.attributes();
for (unsigned int j = 0; j < map.length(); ++j) {
if (map.item(j).nodeName().string() != "class") {
continue;
}
QStringList l = QStringList::split(' ', map.item(j).nodeValue().string());
for (QStringList::ConstIterator it = l.begin(); it != l.end(); ++it) {
if (*it == "photo") {
} else if (*it == "adr") {
value += "ADR:" + extractAddress(node) + "\n";
} else if (*it == "tel") {
value += "TEL;TYPE=VOICE:" + textForNode(node) + "\n";
} else if (*it == "fn") {
name = textForNode(node);
value += "FN:" + name + "\n";
} else if (*it == "url") {
DOM::Node at = node.attributes().getNamedItem("href");
if (!at.isNull()) {
value += "URL:" + at.nodeValue().string().stripWhiteSpace() + "\n";
}
} else if (*it == "email") {
DOM::Node at = node.attributes().getNamedItem("href");
if (!at.isNull()) {
QString v = at.nodeValue().string();
if (v.startsWith("mailto:")) {
v = v.mid(7);
}
value += "EMAIL:" + v.stripWhiteSpace() + "\n";
}
} else if (*it == "org") {
value += "ORG:" + textForNode(node) + "\n";
}
}
}
}
if (!name.isEmpty()) {
value += "END:VCARD\n";
_cards.append(qMakePair(name, value));
}
}
示例6: extractEvent
void KonqMFIcon::extractEvent(DOM::Node node) {
QString name, value = "BEGIN:VCALENDAR\nPRODID:-//Konqueror//EN\nVERSION:2.0\nBEGIN:VEVENT\n";
DOM::NodeList nodes = node.childNodes();
unsigned int n = nodes.length();
for (unsigned int i = 0; i < n; ++i) {
DOM::Node node = nodes.item(i);
DOM::NamedNodeMap map = node.attributes();
for (unsigned int j = 0; j < map.length(); ++j) {
if (map.item(j).nodeName().string() != "class") {
continue;
}
QStringList l = QStringList::split(' ', map.item(j).nodeValue().string());
for (QStringList::ConstIterator it = l.begin(); it != l.end(); ++it) {
if (*it == "url") {
DOM::Node at = node.attributes().getNamedItem("href");
if (!at.isNull()) {
value += "URL:" + at.nodeValue().string().stripWhiteSpace() + "\n";
}
} else if (*it == "dtstart") {
DOM::Node at = node.attributes().getNamedItem("title");
if (!at.isNull()) {
value += "DTSTART:" + at.nodeValue().string().stripWhiteSpace() + "\n";
}
} else if (*it == "dtend") {
DOM::Node at = node.attributes().getNamedItem("title");
if (!at.isNull()) {
value += "DTEND:" + at.nodeValue().string().stripWhiteSpace() + "\n";
}
} else if (*it == "summary") {
name = textForNode(node);
value += "SUMMARY:" + name + "\n";
} else if (*it == "location") {
value += "LOCATION:" + textForNode(node) + "\n";
}
}
}
}
if (!name.isEmpty()) {
value += "END:VEVENT\nEND:VCALENDAR\n";
_events.append(qMakePair(name, value));
}
}
示例7: checkNodeWOffset
void Range::checkNodeWOffset( DOM::Node n, int offset) const
{
checkNode( n );
if( offset < 0 )
throw DOMException( DOMException::INDEX_SIZE_ERR );
if( n.nodeType() != Node::TEXT_NODE )
{
if( (unsigned int)offset > n.childNodes().length() )
throw DOMException( DOMException::INDEX_SIZE_ERR );
}
else
{
Text t;
t = n;
if( t.isNull() || (unsigned)offset > t.length() )
throw DOMException( DOMException::INDEX_SIZE_ERR );
}
}