本文整理汇总了C++中NamedNodeMap::getLength方法的典型用法代码示例。如果您正苦于以下问题:C++ NamedNodeMap::getLength方法的具体用法?C++ NamedNodeMap::getLength怎么用?C++ NamedNodeMap::getLength使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NamedNodeMap
的用法示例。
在下文中一共展示了NamedNodeMap::getLength方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: write
void XmlWriter::write(const NodePtr nodeArg)
{
NodePtr node = nodeArg;
indent+=2;
NamedNodeMap attributes = node->getAttributes();
int nrAttrs = attributes.getLength();
//### Start open tag
spaces();
po("<");
pos(node->getNodeName());
if (nrAttrs>0)
po("\n");
//### Attributes
for (int i=0 ; i<nrAttrs ; i++)
{
NodePtr attr = attributes.item(i);
spaces();
pos(attr->getNodeName());
po("=\"");
pos(attr->getNodeValue());
po("\"\n");
}
//### Finish open tag
if (nrAttrs>0)
spaces();
po(">\n");
//### Contents
spaces();
pos(node->getNodeValue());
//### Children
for (NodePtr child = node->getFirstChild() ;
child.get() ;
child=child->getNextSibling())
{
write(child);
}
//### Close tag
spaces();
po("</");
pos(node->getNodeName());
po(">\n");
indent-=2;
}
示例2: dumpattrs
void dumpattrs(Node *node)
{
NamedNodeMap *attrs;
Attr *a;
uword i;
size_t na;
oratext *qname;
oratext *namespce;
oratext *local;
oratext *prefix;
oratext *value;
if (attrs = node->getAttributes())
{
cout << "\n ATTRIBUTES: \n";
for (na = attrs->getLength(), i = 0; i < na; i++)
{
/* get attr qualified name, local name, namespace, and prefix */
a = (Attr *)attrs->item(i);
qname = namespce = local = prefix = value = (oratext*)" ";
if (a->getQualifiedName() != (oratext*)NULL)
qname = a->getQualifiedName();
if (a->getNamespace() != (oratext*)NULL)
namespce = a->getNamespace();
if (a->getLocal() != (oratext*)NULL)
local = a->getLocal();
if (a->getPrefix() != (oratext*)NULL)
prefix = a->getPrefix();
if (a->getValue() != (oratext*)NULL)
value = a->getValue();
cout << " " << (char*)qname << " = " << (char*)value << "\n";
cout << " Namespace : " << (char*)namespce << "\n";
cout << " Local Name: " << (char*)local << "\n";
cout << " Prefix : " << (char*)prefix << "\n\n";
}
}
cout << "\n";
}
示例3: runTest
/*
* Runs the test case.
*/
void runTest()
{
Document doc;
DocumentType docType;
NamedNodeMap notationList;
Node notation;
int notationType;
doc = (Document) baseT::load("staff", false);
docType = doc.getDoctype();
baseT::assertNotNull(docType, __LINE__, __FILE__);
notationList = docType.getNotations();
baseT::assertNotNull(notationList, __LINE__, __FILE__);
for (unsigned int indexN65609 = 0; indexN65609 != notationList.getLength(); indexN65609++) {
notation = (Node) notationList.item(indexN65609);
notationType = (int) notation.getNodeType();
baseT::assertEquals(12, notationType, __LINE__, __FILE__);
}
}