本文整理汇总了C++中DOMNodeList::getLength方法的典型用法代码示例。如果您正苦于以下问题:C++ DOMNodeList::getLength方法的具体用法?C++ DOMNodeList::getLength怎么用?C++ DOMNodeList::getLength使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DOMNodeList
的用法示例。
在下文中一共展示了DOMNodeList::getLength方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: fileinarchive
void
CSDReader::propertyfile (DOMElement* element)
throw(CSDReadException)
{
DOMNodeList* nodeList;
unsigned int len = 0;
unsigned int i = 0;
//
// fileinarchive
//
nodeList = element->getElementsByTagName(X("fileinarchive"));
len = nodeList->getLength();
for (i = 0; i < len; ++i)
{
fileinarchive((DOMElement*)(nodeList->item(i)));
}
//
// link
//
nodeList = element->getElementsByTagName(X("link"));
len = nodeList->getLength();
for (i = 0; i < len; ++i)
{
link((DOMElement*)(nodeList->item(i)));
}
}
示例2: loadStates
int GameLoop::loadStates(LoadXML* loader)
{
int status = -1;
if(loader != NULL &&
loader->getDocument() != NULL)
{
XMLCh nodeName[100];
XMLString::copyString(nodeName, newString("state").c_str());
DOMNodeList* nodeList = loader->getDocument()->getElementsByTagName(nodeName);
if(nodeList != NULL &&
nodeList->getLength() > 0)
{
for(int i = 0; i < nodeList->getLength(); i++)
{
String type = loader->getTagContent(newString("type"), (DOMElement*)nodeList->item(i));
String name = loader->getTagContent(newString("name"), (DOMElement*)nodeList->item(i));
BaseState* state = this->newState(name, type);
String camera = loader->getTagContent(newString("camera"), (DOMElement*)nodeList->item(i));
String resources = loader->getTagContent(newString("resources"), (DOMElement*)nodeList->item(i));
if(state != NULL)
{
state->setName(name);
state->setResourceXML(resources);
state->setCamera(camera);
}
}
}
}
return status;
}
示例3: parse
bool FDPLoader::parse()
{
m_bindings.clear();
m_morphTargetsMeshInfos.clear();
m_faceEntityMeshInfo.clear();
// get the header
DOMNodeList* nodes = m_pDoc->getElementsByTagName(XercesString("head"));
if(!nodes || nodes->getLength() != 1) // sth wrong
return false;
if(!parseHeader(nodes->item(0)) )
return false;
// get the source info
nodes = m_pDoc->getElementsByTagName(XercesString("source"));
if(!nodes || nodes->getLength() != 1) // sth wrong
return false;
parseSource(nodes->item(0));
// process fdp's now
nodes = m_pDoc->getElementsByTagName(XercesString("fdp"));
XMLSize_t sz = nodes->getLength();
for(XMLSize_t i = 0; i < sz; ++i)
loadFDPItem(nodes->item(i));
return true;
}
示例4: metagame
void Generation::GenerationImpl::getGeneration(DOMElement *node) {
XMLCh tempStr[20];
XMLString::transcode("id", tempStr, 19);
DOMNode *p = node->getAttributes()->getNamedItem(tempStr);
if (p) {
m_id = getStringNodeValue(p);
}
XMLString::transcode("name", tempStr, 19);
DOMNodeList *list = node->getElementsByTagName(tempStr);
if (list->getLength() != 0) {
m_name = getTextFromElement((DOMElement *)list->item(0));
}
XMLString::transcode("metagames", tempStr, 19);
list = node->getElementsByTagName(tempStr);
if (list->getLength() != 0) {
DOMElement *metagames = (DOMElement *)list->item(0);
XMLString::transcode("metagame", tempStr, 19);
list = metagames->getElementsByTagName(tempStr);
const int length = list->getLength();
for (int i = 0; i < length; ++i) {
DOMElement *item = (DOMElement *)list->item(i);
MetagamePtr metagame(new Metagame());
metagame.get()->m_impl->getMetagame(item);
metagame.get()->m_impl->m_idx = i;
metagame.get()->m_impl->m_generation = m_owner;
m_metagames.push_back(metagame);
}
}
}
示例5: getEntity
string ClsSettingsReader::getEntity (string strEntityName ) {
if(iSysSettingReaderState != PARSER_BUFFER_PARSED){
ClsSettingsReaderException clsSettingsReaderException(ClsSettingsReaderException::BUFFER_NOT_PARSED);
throw clsSettingsReaderException;
}
DOMNode* dnTemp=NULL;
DOMNodeList* dnlstTemp = ddocIqrSetting->getElementsByTagName(XMLString::transcode(strEntityName.c_str()));
if ( dnlstTemp->getLength() == 1){
dnTemp = dnlstTemp->item(0);
} else if ( dnlstTemp->getLength() < 1) {
ClsSettingsReaderException clsSettingsReaderException(ClsSettingsReaderException::ENTITY_NOT_FOUND);
throw clsSettingsReaderException;
}
string strValue = "";
DOMNode* dnValue = dnTemp->getFirstChild();
if(dnValue!=NULL){
strValue = XMLString::transcode(dnValue->getNodeValue());
}
return strValue;
};
示例6: load
void SC_XMLNodeConfig::load()
{
TRY(SC_XMLNodeConfig::load());
mNodeMap->clear();
createTreeFromFile(mDocPath);
RPMS_TRACE(XML_NOD_LOG, "Extracting RPMS node listing");
XMLCh * nodelist = XMLString::transcode( SS_Ini::instance()->getString("xml_elemnames", "hostlist").c_str() );
DOMNodeList *list = getDoc()->getDocumentElement()->getElementsByTagName( nodelist );
if( 1 < list->getLength() )
{
throw SX_XMLUtil("More than one node list defined in [" + mDocPath + "]");
}
// get the items in the group
DOMNodeList *nodes = list->item(0)->getChildNodes();
for( int i = 0; i < nodes->getLength(); ++i )
{
// we are only interested in elements
DOMElement * cfgNode = dynamic_cast<DOMElement*>( nodes->item(i) );
if( cfgNode )
{
ST_SPointer<SC_NodeConfig> c = SC_NodeConfig::build(cfgNode);
add( c->getHostName(), c );
}
}
//clean up
XMLString::release(&nodelist);
CATCH;
}
示例7: stampDocument
// 2006/12/16
void stampDocument(DOMElement* root) {
DOMElement* meta = NULL;
DOMElement* macastamps = NULL;
DOMElement* stamp = NULL;
stamp = (root->getOwnerDocument())->createElement(XMLString::transcode("maca_stamp"));
stamp->setAttribute(XMLString::transcode("module"),
XMLString::transcode(_INSTALLED_NAME_));
stamp->setAttribute(XMLString::transcode("version"),
XMLString::transcode(_VERSION_));
stamp->setAttribute(XMLString::transcode("timestamp"),
XMLString::transcode(getTimestamp().c_str()));
DOMNodeList* metaList = root->getElementsByTagName(XMLString::transcode("meta"));
if (metaList->getLength() == 0) { // NO meta Element
meta = (root->getOwnerDocument())->createElement(XMLString::transcode("meta"));
macastamps =
(root->getOwnerDocument())->createElement(XMLString::transcode("maca_stamps"));
meta->appendChild(macastamps);
root->insertBefore(meta,root->getFirstChild());
} else { // meta Element
meta = (DOMElement*)metaList->item(0);
DOMNodeList* macastampsList =
meta->getElementsByTagName(XMLString::transcode("maca_stamps"));
if (macastampsList->getLength() == 0) { // NO macastamps Element
macastamps =
(root->getOwnerDocument())->createElement(XMLString::transcode("maca_stamps"));
meta->appendChild(macastamps);
} else { // macastamps Element
macastamps = (DOMElement*)macastampsList->item(0);
}
}
macastamps->appendChild(stamp);
}
示例8: XS
/**
* Create PerfPart element
*/
PerfPart::PerfPart( PMLDocument *doc, DOMElement *element ){
m_doc = doc;
m_element = element;
DOMDocument *domdoc = m_element->getOwnerDocument();
const XMLCh *partID = m_element->getAttribute( XS("part") );
DOMElement *root = m_element->getOwnerDocument()->getDocumentElement();
DOMNodeList *parts = root->getElementsByTagName(XS("part"));
for( unsigned int i=0; i<parts->getLength(); i++ ){
DOMElement *e = (DOMElement*)parts->item(i);
cout << " perf " << XS( m_element->getAttribute(XS("id")))
<< " score " << XS( e->getAttribute(XS("part")) )
<< endl;
if( !strcmp(XS( m_element->getAttribute(XS("id")) ), XS( e->getAttribute(XS("part")) )) ){
m_scorePart = new ScorePart( m_doc, e );
}
}
DOMNodeList *nl = m_element->getElementsByTagName(XS(PNote::Tag));
for( int i=0; i<nl->getLength(); i++ ){
m_notes.push_back( new PNote( m_doc, (DOMElement*)nl->item(i) ) );
}
}
示例9: HandlerBase
map<string, DatasetSpecification> Specifications::readDatasetIndex(string str){
map<string, DatasetSpecification> result;
XERCES_CPP_NAMESPACE_USE
XMLPlatformUtils::Initialize();
XercesDOMParser parser;
parser.setValidationScheme(XercesDOMParser::Val_Always);
HandlerBase errHandler;// = (ErrorHandler*) new HandlerBase();
parser.setErrorHandler(&errHandler);
parser.parse(str.c_str());
DOMDocument * doc = parser.getDocument();
DOMElement* elementRoot = doc->getDocumentElement();
DOMNodeList *entries =
elementRoot->getElementsByTagName(XMLString::transcode("dataset"));
cout << "Databases in index:\n";
for(size_t i = 0; i < entries->getLength(); ++i){
DOMNode *current = entries->item(i);
DatasetSpecification dss;
dss.name = XMLString::transcode(current->getAttributes()->
getNamedItem(XMLString::transcode("name"))->
getNodeValue());
dss.root = XMLString::transcode(current->getAttributes()->
getNamedItem(XMLString::transcode("root"))->
getNodeValue());
cout << " name: " << dss.name << " root: " << dss.root << endl;
DOMNodeList *categories = current->getChildNodes();
for(size_t j = 0; j < categories->getLength(); ++j)
if((string) XMLString::transcode(categories->item(j)->getNodeName()) ==
"category")
dss.categories.push_back(XMLString::transcode(categories->item(j)->getTextContent()));
result[dss.name] = dss;
}
return result;
}
示例10: readData
void TimeSourceManager::readData(SaveGameFileReader* reader)
{
reader->initializeXml();
DOMNodeList* rootNodeList = reader->getDocument()->getDocumentElement()->getElementsByTagName(AutoXMLCh(getXmlNodeIdentifier().c_str()).data());
if(rootNodeList->getLength())
{
DOMNodeList* xmlTimeSources = static_cast<DOMElement*>(rootNodeList->item(0))->getElementsByTagName(AutoXMLCh("gameobject").data()); //there should be only one "gameobjects" node
if(xmlTimeSources->getLength())
{
for(XMLSize_t childIdx = 0; childIdx < xmlTimeSources->getLength(); childIdx++)
{
DOMNode* xmlTimeSource = xmlTimeSources->item(childIdx);
if(xmlTimeSource->getNodeType() == DOMNode::ELEMENT_NODE)
{
TimeSource::TimeSourceType ID = (TimeSource::TimeSourceType)reader->getAttributeValueAsInteger(
static_cast<DOMElement*>(xmlTimeSource), "ID");
PropertyRecordPtr properties = reader->getPropertiesAsRecord(static_cast<DOMElement*>(xmlTimeSource));
std::map<TimeSource::TimeSourceType, TimeSource*>::const_iterator it_time_sources = mTimeSources.find(ID);
if(it_time_sources != mTimeSources.end())
it_time_sources->second->setClock(properties->toPropertyMap()["time"].toInt());
}
}
}
}
reader->shutdownXml();
}
示例11: if
void
CSDReader::implementation (DOMElement* element)
throw(CSDReadException)
{
DOMNodeList* nodeList;
unsigned int len = 0;
unsigned int i = 0;
//
// dependency
//
nodeList = element->getElementsByTagName(X("dependency"));
len = nodeList->getLength();
for (i = 0; i < len; ++i)
{
dependency((DOMElement*)(nodeList->item(i)));
}
//
// descriptor
//
nodeList = element->getElementsByTagName(X("descriptor"));
len = nodeList->getLength();
if(len == 1)
{
ccd_file_ = descriptor((DOMElement*)(nodeList->item(0)));
}
else if(len > 1)
{
NORMAL_ERR( "CSDReader: multiple descriptors" );
}
//
// code
//
nodeList = element->getElementsByTagName(X("code"));
len = nodeList->getLength();
if(len == 0)
{
NORMAL_ERR2( "CSDReader: missing code for ", data_->uuid );
throw CSDReadException();
}
for (i = 0; i < len; ++i)
{
code((DOMElement*)(nodeList->item(i)));
}
//
// os
//
nodeList = element->getElementsByTagName(X("os"));
len = nodeList->getLength();
for (i = 0; i < len; ++i)
{
os((DOMElement*)(nodeList->item(i)));
}
// more todo
}
示例12: ParseDeviceContexts
bool CConfigParser::ParseDeviceContexts(DOMNodeList* deviceContextNodes, ADeviceListener& configClass)
{
ASSERT(deviceContextNodes->getLength() == 1);
DOMNode* deviceContextNode = deviceContextNodes->item(0);
DOMNodeList* deviceContexts = deviceContextNode->getChildNodes();
for(unsigned long idx = 0; idx < deviceContexts->getLength(); idx++)
{
DOMNode* currentDeviceContext = deviceContexts->item(idx);
wstring deviceContextNodeName = currentDeviceContext->getNodeName();
if(deviceContextNodeName.compare(L"#text") == 0)
continue;
if(deviceContextNodeName.compare(L"#comment") == 0)
continue;
wstring deviceContextName = currentDeviceContext->getAttributes()->getNamedItem(L"name")->getNodeValue();
wstring deviceName = currentDeviceContext->getAttributes()->getNamedItem(L"device")->getNodeValue();
bool gestures = false;
if(currentDeviceContext->getAttributes()->getNamedItem(L"gestures") != NULL)
gestures = true;
// Create the device context to add
CDeviceContext* deviceContextToAdd = NULL;
if(configClass.GetDevices()[deviceName]->GetType().compare("mouse") == 0)
deviceContextToAdd = new CMouseDeviceContext(gestures, deviceName);
else
deviceContextToAdd = new CDeviceContext(gestures, deviceName);
// Get the device contexts axis and buttons added
if(currentDeviceContext->hasChildNodes())
{
unsigned char axeIdx = 0;
DOMNodeList* children = currentDeviceContext->getChildNodes();
unsigned long childCount = children->getLength();
for(unsigned long idx = 0; idx < childCount; idx++)
{
DOMNode* childNode = children->item(idx);
wstring nodeName = childNode->getNodeName();
if(nodeName.compare(L"axe") == 0)
{
ParseAxe(childNode, configClass.GetActions(), deviceContextToAdd, axeIdx);
axeIdx++;
}
if(nodeName.compare(L"buttons") == 0)
ParseButtons(childNode, configClass.GetActions(), deviceContextToAdd);
if(nodeName.compare(L"gesture") == 0)
ParseGesture(childNode, configClass.GetActions(), deviceContextToAdd);
}
}
configClass.AddDeviceContext(deviceContextName, deviceContextToAdd);
TRACE("Device Context <%S> is 0x%X\r\n", deviceContextName.c_str(), deviceContextToAdd);
}
return true;
}
示例13: parsePropertyDependencies
void SPDImplementation::parsePropertyDependencies(DOMElement * _elem)
{
DEBUG(4, SPDImplementation, "In parsePropertyDependencies.");
std::vector <DOMNode*> _list;
tmpXMLStr = XMLString::transcode("dependency");
DOMNodeList *nodeList = _elem->getElementsByTagName(tmpXMLStr);
sweetd(tmpXMLStr);
unsigned int len;
DOMElement *_tmpElement;
for (unsigned int i = 0; i < nodeList->getLength (); i++) {
tmpXMLStr = XMLString::transcode("propertyref");
DOMNodeList *childNodeList =
((DOMElement *) nodeList->item (i))->getElementsByTagName(tmpXMLStr);
sweetd(tmpXMLStr);
len = childNodeList->getLength();
if (len > 0) {
for (unsigned int i = 0; i < len; i++)
_list.push_back (childNodeList->item (i));
}
}
len = _list.size();
const XMLCh *_tmp;
const XMLCh *_tmp2;
char *_id;
char *_val;
if (len > 0) {
propDep.length (len);
for (unsigned int i = 0; i < len; i++) {
_tmpElement = (DOMElement *) _list[i];
tmpXMLStr = XMLString::transcode("refid");
_tmp = _tmpElement->getAttribute(tmpXMLStr);
sweetd(tmpXMLStr);
_id = XMLString::transcode (_tmp);
propDep[i].id = CORBA::string_dup(_id);
tmpXMLStr = XMLString::transcode("value");
_tmp2 = _tmpElement->getAttribute(tmpXMLStr);
_val = XMLString::transcode(_tmp2);
propDep[i].value <<= _val;
}
}
}
示例14: throw
string core::xml::getAllTextNodes(DOMNode *const node) throw () {
stringstream result;
DOMNodeList *children = node->getChildNodes();
if (children->getLength() > 1) {
for (unsigned int i = 0 ; i < children->getLength() ; i++) {
result << getAllTextNodes(children->item(i));
}
} else {
// Trim
result << xts(node->getTextContent(), true).asString();
}
return result.str();
}
示例15: getValue
string CXmlConfig::getValue(DOMNode* parentNode, const string& itemName)
{
string strValue;
string strName;
DOMNode* firstChildNode = NULL;
charArrayToString(parentNode->getNodeName(), strName);
if (strName == itemName)
{
firstChildNode = parentNode->getFirstChild();
if (firstChildNode != NULL) charArrayToString(firstChildNode->getNodeValue(), strValue);
return strValue;
}
DOMNodeList* nodeList = parentNode->getChildNodes();
for (unsigned int i = 0; i < nodeList->getLength(); ++i)
{
DOMNode* nodeTemp = nodeList->item(i);
if (nodeTemp->getNodeType() == DOMNode::ELEMENT_NODE)
{
charArrayToString(nodeTemp->getNodeName(), strName);
if (strName == itemName)
{
firstChildNode = nodeTemp->getFirstChild();
if (firstChildNode != NULL) charArrayToString(firstChildNode->getNodeValue(), strValue);
break;
}
}
}
return strValue;
}