本文整理汇总了C++中TiXmlDocument::FirstChildElement方法的典型用法代码示例。如果您正苦于以下问题:C++ TiXmlDocument::FirstChildElement方法的具体用法?C++ TiXmlDocument::FirstChildElement怎么用?C++ TiXmlDocument::FirstChildElement使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TiXmlDocument
的用法示例。
在下文中一共展示了TiXmlDocument::FirstChildElement方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: clientXMLHasValidValues
bool XMLLoader::clientXMLHasValidValues(TiXmlDocument xmlFile){
TiXmlElement *connection = xmlFile.FirstChildElement(kClientTag)->FirstChildElement(kConnectionTag);
const char* clientIP = connection->FirstChildElement(kIPTag)->GetText();
struct sockaddr_in sa;
int success = inet_pton(AF_INET, clientIP, &(sa.sin_addr));
if (success != 1){
this->logWriter->writeInvalidValueForElementInXML(kIPTag);
return false;
}
const char *clientPort = connection->FirstChildElement(kIPTag)->NextSiblingElement(kPortTag)->GetText();
std::stringstream portStrValue;
portStrValue << clientPort;
unsigned int portIntValue;
portStrValue >> portIntValue;
if (portIntValue <= 0 || portIntValue > kMaxNumberOfValidPort) {
this->logWriter->writeInvalidValueForElementInXML(kPortTag);
return false;
}
TiXmlElement *firstMessageElement = xmlFile.FirstChildElement(kClientTag)->FirstChildElement(kConnectionTag)->NextSiblingElement(kMessagesTag)->FirstChildElement(kMessageTag);
for(TiXmlElement *message = firstMessageElement; message != NULL; message = message->NextSiblingElement(kMessageTag)) {
const char *messageID = message->FirstChildElement(kMessageIDTag)->GetText();
this->messageIDList.push_back(messageID);
string messageType = stringFromChar(message->FirstChildElement(kMessageTypeTag)->GetText());
if ((messageType.compare(kMessageTypeInt) != 0) && (messageType.compare(kMessageTypeString) != 0) && (messageType.compare(kMessageTypeChar) != 0) && (messageType.compare(kMessageTypeDouble) != 0)) {
this->logWriter->writeInvalidValueForElementInXML(kMessageTypeTag);
return false;
}
}
return true;
}
示例2: CreateFromFile
bool cOpenALSoundEnvironment::CreateFromFile(const tString &asFile)
{
tString strType;
TiXmlDocument doc;
if (!doc.LoadFile(asFile.c_str()))
return false;
TiXmlElement* pMain = doc.FirstChildElement("SoundEnvironment")->FirstChildElement("Main");
if (pMain)
{
strType = pMain->Attribute("Type");
mstrName = pMain->Attribute("Name");
}
float* pfTemp;
TiXmlElement* pParams = doc.FirstChildElement("SoundEnvironment")->FirstChildElement("Parameters");
if ( (pParams == NULL) || (strType.compare("OpenAL")!=0) )
{
doc.Clear();
return false;
}
mfDensity = cString::ToFloat(pParams->Attribute("Density"),0);
mfDiffusion = cString::ToFloat(pParams->Attribute("Diffusion"),0);
mfGain = cString::ToFloat(pParams->Attribute("Gain"),0);
mfGainHF = cString::ToFloat(pParams->Attribute("GainHF"),0);
mfGainLF = cString::ToFloat(pParams->Attribute("GainLF"),0);
mfDecayTime = cString::ToFloat(pParams->Attribute("DecayTime"),0);
mfDecayHFRatio = cString::ToFloat (pParams->Attribute("DecayHFRatio"),0);
mfDecayLFRatio = cString::ToFloat (pParams->Attribute("DecayLFRatio"),0);
mfReflectionsGain = cString::ToFloat(pParams->Attribute("ReflectionsGain"),0);
mfReflectionsDelay = cString::ToFloat(pParams->Attribute("ReflectionsDelay"),0);
pfTemp = cString::ToVector3f(pParams->Attribute("ReflectionsPan"),cVector3f(0)).v;
mfReflectionsPan[0] = pfTemp[0];
mfReflectionsPan[1] = pfTemp[1];
mfReflectionsPan[2] = pfTemp[2];
mfLateReverbGain = cString::ToFloat(pParams->Attribute("LateReverbGain"),0);
mfLateReverbDelay = cString::ToFloat(pParams->Attribute("LateReverbDelay"),0);
pfTemp = cString::ToVector3f(pParams->Attribute("LateReverbPan"),cVector3f(0)).v;
mfLateReverbPan[0] = pfTemp[0];
mfLateReverbPan[1] = pfTemp[1];
mfLateReverbPan[2] = pfTemp[2];
mfEchoTime = cString::ToFloat(pParams->Attribute("EchoTime"),0);
mfEchoDepth = cString::ToFloat(pParams->Attribute("EchoDepth"),0);
mfModulationTime = cString::ToFloat(pParams->Attribute("ModulationTime"),0);
mfModulationDepth = cString::ToFloat(pParams->Attribute("ModulationDepth"),0);
mfAirAbsorptionGainHF = cString::ToFloat(pParams->Attribute("AirAbsorptionGainHF"),0);
mfHFReference = cString::ToFloat(pParams->Attribute("HFReference"),0);
mfLFReference = cString::ToFloat(pParams->Attribute("LFReference"),0);
mfRoomRolloffFactor =cString::ToFloat(pParams->Attribute("RoomRolloffFactor"),0);
mbDecayHFLimit = cString::ToInt(pParams->Attribute("DecayHFLimit"),0);
doc.Clear();
pParams = NULL;
return true;
}
示例3: C
mitk::NavigationDataSet::Pointer mitk::NavigationDataReaderXML::Read(std::string fileName)
{
//save old locale
char * oldLocale;
oldLocale = setlocale( LC_ALL, 0 );
//define own locale
std::locale C("C");
setlocale( LC_ALL, "C" );
m_FileName = fileName;
TiXmlDocument document;
if ( !document.LoadFile(fileName))
{
mitkThrowException(mitk::IGTIOException) << "File '"<<fileName<<"' could not be loaded.";
}
TiXmlElement* m_DataElem = document.FirstChildElement("Version");
if(!m_DataElem)
{
// for backwards compatibility of version tag
m_DataElem = document.FirstChildElement("Data");
if(!m_DataElem)
{
mitkThrowException(mitk::IGTIOException) << "Data element not found.";
}
}
if (m_DataElem->QueryIntAttribute("Ver", &m_FileVersion) != TIXML_SUCCESS)
{
if (m_DataElem->QueryIntAttribute("version", &m_FileVersion) != TIXML_SUCCESS)
{
mitkThrowException(mitk::IGTIOException) << "Version not specified in XML file.";
}
}
if (m_FileVersion != 1)
{
mitkThrowException(mitk::IGTIOException) << "File format version "<<m_FileVersion<<" is not supported.";
}
m_parentElement = document.FirstChildElement("Data");
if(!m_parentElement)
{
mitkThrowException(mitk::IGTIOException) << "Data element not found.";
}
m_parentElement->QueryIntAttribute("ToolCount", &m_NumberOfOutputs);
mitk::NavigationDataSet::Pointer navigationDataSet = this->ReadNavigationDataSet();
//switch back to old locale
setlocale( LC_ALL, oldLocale );
return navigationDataSet;
}
示例4: LoadSettings
int NppFTP::LoadSettings() {
int result = 0;
char xmlPath[MAX_PATH];
char * utf8Store = SU::TCharToCP(m_configStore, CP_ACP);
strcpy(xmlPath, utf8Store);
::PathCombineA(xmlPath, utf8Store, "NppFTP.xml");
TiXmlDocument settingsDoc = TiXmlDocument(xmlPath);
settingsDoc.LoadFile();
strcpy(xmlPath, utf8Store);
::PathCombineA(xmlPath, utf8Store, "Certificates.xml");
SU::FreeChar(utf8Store);
TiXmlDocument certificatesDoc = TiXmlDocument(xmlPath);
certificatesDoc.LoadFile();
TiXmlElement* ftpElem = settingsDoc.FirstChildElement("NppFTP");
if (!ftpElem) {
result = 1;
return result;
}
m_ftpSettings->LoadSettings(ftpElem);
TiXmlElement * profilesElem = ftpElem->FirstChildElement(FTPProfile::ProfilesElement);
if (!profilesElem) {
m_profiles.clear();
result = 1;
} else {
m_profiles = FTPProfile::LoadProfiles(profilesElem);
for(size_t i = 0; i < m_profiles.size(); i++) {
m_profiles.at(i)->AddRef();
m_profiles.at(i)->SetCacheParent(m_ftpSettings->GetGlobalCache());
}
}
ftpElem = certificatesDoc.FirstChildElement("NppFTP");
if (!ftpElem) {
m_certificates.clear();
result = 1;
} else {
TiXmlElement * dersElem = ftpElem->FirstChildElement(SSLCertificates::DERsElem);
if (!dersElem) {
m_certificates.clear();
result = 1;
} else {
vDER derVect = SSLCertificates::LoadDER(dersElem);
m_certificates = SSLCertificates::ConvertDERVector(derVect);
SSLCertificates::FreeDERVector(derVect);
}
}
return result;
}
示例5: GetXmlFile
// Opens the specified XML file if it exists or creates a new one otherwise.
// Returns 0 on error.
TiXmlElement* GetXmlFile(wxFileName file, bool create /*=true*/, wxString* error /*=0*/)
{
if (wxFileExists(file.GetFullPath()) && file.GetSize() > 0)
{
// File does exist, open it
TiXmlDocument* pXmlDocument = new TiXmlDocument;
pXmlDocument->SetCondenseWhiteSpace(false);
if (!LoadXmlDocument(pXmlDocument, file.GetFullPath(), error))
{
delete pXmlDocument;
return 0;
}
TiXmlElement* pElement = pXmlDocument->FirstChildElement("FileZilla3");
if (!pElement)
{
if (pXmlDocument->FirstChildElement())
{
// Not created by FileZilla3
delete pXmlDocument;
if (error)
*error = _("Unknown root element, the file does not appear to be generated by FileZilla.");
return 0;
}
pElement = pXmlDocument->LinkEndChild(new TiXmlElement("FileZilla3"))->ToElement();
}
return pElement;
}
else
{
// File does not exist
if (!create)
return 0;
// create new XML document
TiXmlDocument* pXmlDocument = new TiXmlDocument();
pXmlDocument->SetCondenseWhiteSpace(false);
pXmlDocument->LinkEndChild(new TiXmlDeclaration("1.0", "UTF-8", "yes"));
pXmlDocument->LinkEndChild(new TiXmlElement("FileZilla3"));
if (!SaveXmlFile(file, pXmlDocument, 0))
{
delete pXmlDocument;
return 0;
}
return pXmlDocument->FirstChildElement("FileZilla3");
}
}
示例6: CompareTrees
bool CompareTrees(const TiXmlDocument & code, const TiXmlDocument & doc, std::string & errTxt)
{
const TiXmlNode * dNode = doc.FirstChildElement();
const TiXmlNode * cNode = code.FirstChildElement();
if(dNode->ValueStr() != "crava")
errTxt = "Error: Documentation tree corrupt.\n";
if(cNode->ValueStr() != "crava")
errTxt = "Error: Code tree corrupt.\n";
if(errTxt == "")
CompareBranches(dNode, cNode, errTxt);
return(errTxt == "");
}
示例7: loadProperties
void Properties::loadProperties(char* filename) {
TiXmlDocument * doc = new TiXmlDocument();
if (doc->LoadFile(filename, TIXML_ENCODING_UTF8)) {
char *host = const_cast<char*>(doc->FirstChildElement()->GetText());
char *port = const_cast<char*>(doc->FirstChildElement()->NextSiblingElement()->GetText());
//get host pair
this->properties.insert(std::pair<char*, char*>("host", host));
//get port pair
this->properties.insert(std::pair<char*, char*>("port", port));
}
}
示例8: lock
TiXmlElement *COptions::GetXML()
{
simple_lock lock(m_mutex);
USES_CONVERSION;
CStdString xmlFileName = GetExecutableDirectory() + _T("FileZilla Server.xml");
char* bufferA = T2A(xmlFileName);
if (!bufferA) {
return 0;
}
TiXmlDocument *pDocument = new TiXmlDocument;
if (!pDocument->LoadFile(bufferA)) {
delete pDocument;
return NULL;
}
TiXmlElement* pElement = pDocument->FirstChildElement("FileZillaServer");
if (!pElement) {
delete pDocument;
return NULL;
}
// Must call FreeXML
m_mutex.lock();
return pElement;
}
示例9: Load
bool COneCleanSetting::Load()
{
bool retval = false;
TiXmlDocument xmlDoc;
const TiXmlElement *pXmlSetting = NULL;
const TiXmlElement *pXmlStrings = NULL;
const TiXmlElement *pXmlIntegers = NULL;
const TiXmlElement *pXmlChild = NULL;
KFilePath settingPath = KFilePath::GetFilePath(_Module.m_hInst);
settingPath.RemoveFileSpec();
settingPath.Append(L"cfg\\onekeyclean.xml");
if (!xmlDoc.LoadFile(UnicodeToAnsi(settingPath.value()).c_str(), TIXML_ENCODING_UTF8))
goto clean0;
pXmlSetting = xmlDoc.FirstChildElement("setting");
if (!pXmlSetting)
goto clean0;
pXmlStrings = pXmlSetting->FirstChildElement("strings");
if (pXmlStrings)
{
pXmlChild = pXmlStrings->FirstChildElement("entry");
while (pXmlChild)
{
std::string strName, strValue;
strName = pXmlChild->Attribute("name");
strValue = pXmlChild->Attribute("value");
if (strcmp(strName.c_str(), "default_entrys") != 0)
{
m_vStringStore[strName] = Utf8ToUnicode(strValue);
}
pXmlChild = pXmlChild->NextSiblingElement("entry");
}
}
pXmlIntegers = pXmlSetting->FirstChildElement("integers");
if (pXmlIntegers)
{
pXmlChild = pXmlIntegers->FirstChildElement("entry");
while (pXmlChild)
{
std::string strName;
int nValue;
strName = pXmlChild->Attribute("name");
pXmlChild->QueryIntAttribute("value", &nValue);
m_vIntegerStore[strName] = nValue;
pXmlChild = pXmlChild->NextSiblingElement("entry");
}
}
retval = true;
clean0:
return retval;
}
示例10: Load
void ConfigValues::Load(const std::string &filename)
{
TiXmlDocument doc;
doc.LoadFile(Assets::GetContentPath() + filename);
TiXmlElement *xmlValues = doc.FirstChildElement("config");
if (xmlValues)
{
TiXmlElement *xmlValue = xmlValues->FirstChildElement("value");
while (xmlValue)
{
std::string name = XMLReadString(xmlValue, "name");
if (xmlValue->Attribute("float"))
instance->floats[name] = XMLReadFloat(xmlValue, "float");
if (xmlValue->Attribute("string"))
instance->strings[name] = XMLReadString(xmlValue, "string");
if (xmlValue->Attribute("int"))
instance->ints[name] = XMLReadInt(xmlValue, "int");
if (xmlValue->Attribute("bool"))
instance->bools[name] = XMLReadBool(xmlValue, "bool");
if (xmlValue->Attribute("vector2"))
instance->vector2s[name] = XMLReadVector2(xmlValue, "vector2");
xmlValue = xmlValue->NextSiblingElement("value");
}
}
}
示例11: UpdateStats
void Artifact::UpdateStats(const std::string & spec)
{
#ifdef WITH_XML
// parse artifacts.xml
TiXmlDocument doc;
const TiXmlElement* xml_artifacts = NULL;
if(doc.LoadFile(spec.c_str()) &&
NULL != (xml_artifacts = doc.FirstChildElement("artifacts")))
{
size_t index = 0;
const TiXmlElement* xml_artifact = xml_artifacts->FirstChildElement("artifact");
for(; xml_artifact && index < UNKNOWN; xml_artifact = xml_artifact->NextSiblingElement("artifact"), ++index)
{
int value;
artifactstats_t* ptr = &artifacts[index];
xml_artifact->Attribute("disable", &value);
if(value) ptr->bits |= ART_DISABLED;
xml_artifact->Attribute("extra", &value);
if(value && !SkipExtra(index)) ptr->extra = value;
Artifact art(index);
}
}
else
VERBOSE(spec << ": " << doc.ErrorDesc());
#endif
}
示例12: LoadConfig
bool CXmlConfig::LoadConfig(const char* szRootNodeName,const char* szFileName)
{
if( !szRootNodeName )
GenErr("配置文件的根节点名称不能为NULL");
TiXmlDocument XmlDoc;
if( !XmlDoc.LoadFile( szFileName ) )
return false;
TiXmlElement* pRoot = XmlDoc.FirstChildElement( szRootNodeName );
if( !pRoot )
{
ostringstream strm;
strm<<"配置文件的根节点不是\""<<szRootNodeName<<"\"";
GenErr( strm.str() );
}
Clear();
m_pRoot = static_cast<TiXmlElement*>( pRoot->Clone() );
return true;
}
示例13: LoadInSourceMode
bool wxsItemResData::LoadInSourceMode()
{
// TODO: Check if source / header files have required blocks of code
TiXmlDocument Doc;
if ( !TinyXML::LoadDocument(m_WxsFileName,&Doc) )
{
Manager::Get()->GetLogManager()->DebugLog(F(_T("wxSmith: Error loading wxs file (Col: %d, Row:%d): ") + cbC2U(Doc.ErrorDesc()),Doc.ErrorCol(),Doc.ErrorRow()));
return false;
}
TiXmlElement* wxSmithNode = Doc.FirstChildElement("wxsmith");
if ( !wxSmithNode ) return false;
TiXmlElement* Object = wxSmithNode->FirstChildElement("object");
if ( !Object ) return false;
/*
if ( cbC2U(Object->Attribute("name")) != m_ClassName ) return false;
if ( cbC2U(Object->Attribute("class")) != m_ClassType ) return false;
*/
RecreateRootItem();
if ( !m_RootItem ) return false;
m_RootItem->XmlRead(Object,true,true);
LoadToolsReq(Object,true,true);
return true;
}
示例14: TiXmlDocument
Progress::Progress(void)
{
Logger::DiagnosticOut() << "Loading progress record\n";
//Load XML
TiXmlDocument doc = TiXmlDocument("Progress.xml");
doc.LoadFile();
TiXmlElement* root = doc.FirstChildElement("Progress");
if(root)
{
TiXmlElement* record = root->FirstChildElement("Record");
int record_number = 0;
while(record)
{
std::string filename = "";
bool completed = false;
bool error = false;
error |= (record->QueryValueAttribute("Filename", &filename) != TIXML_SUCCESS);
error |= (record->QueryValueAttribute("Completed", &completed) != TIXML_SUCCESS);
if(error)
Logger::DiagnosticOut() << "Error parsing record number: " << record_number << ". Possible data: Filename:" << filename << ", completed: " << completed << "\n";
else
{
ProgressRecord pr;
pr.completed = completed;
progress_[filename] = pr;
}
record = record->NextSiblingElement("Record");
record_number++;
}
}
}
示例15: GetSettingFromFile
std::string CInitializer::GetSettingFromFile(std::string file, const std::string& name)
{
TiXmlDocument xmldoc;
if (!xmldoc.LoadFile(file.c_str()))
return "";
TiXmlElement* main = xmldoc.FirstChildElement("FileZilla3");
if (!main)
return "";
TiXmlElement* settings = main->FirstChildElement("Settings");
if (!settings)
return "";
for (TiXmlElement* setting = settings->FirstChildElement("Setting"); setting; setting = setting->NextSiblingElement("Setting"))
{
const char* nodeVal = setting->Attribute("name");
if (!nodeVal || strcmp(nodeVal, name.c_str()))
continue;
TiXmlNode* textNode = setting->FirstChild();
if (!textNode || !textNode->ToText())
continue;
return mkstr(textNode->Value());
}
return "";
}