I wanted to make a module that uses ftp for automatic updates. I needed to read xml documents and check against server data and then download. I thought I could solve it by following online tutorials, but I still encountered many problems in the middle. Here I record the steps.
Configuration
- Visual Studio 2022
- tinyxml, download link: TinyXML
Steps
- Downloading the tinyxml package directly using nuget will eventually report an error, because the package is compiled for Win32, so an error will appearing the end.
- According to the downloaded package, open it with visual studio, and create a new configuration manager, create
x64configuration in it, then compile the tinyxml project file. You can compileDebug,Releaseversions at once.
- After generation, put the following files into the folder for later reference/quotation

4. After completing these two steps, enter Project -> Properties -> C/C++ -> Additional Include Directories, and add the .cpp, .h folders.
5. We also need to reference the lib file in the header file, otherwise an error will be reported.
#pragma comment(lib,"D:\\C++ Programming\\MFCAutoUpdateApplication\\src\\tinyxml\\lib\\debug\\tinyxml.lib")
- Below is a code example, concatenating to MFC to display node name
#pragma once
#include <string>
#include "tinystr.h"
#include "tinyxml.h"
#include <iostream>
#pragma comment(lib,"D:\\C++ Programming\\MFCAutoUpdateApplication\\src\\tinyxml\\lib\\debug\\tinyxml.lib")
using namespace std;
class ReadXML
{
public:
ReadXML(const char* path);
std::string parentNode;
std::string childNode;
private:
void GetXMLData();
};
inline ReadXML::ReadXML(const char* path)
{
TiXmlDocument* doc = new TiXmlDocument();
if (!doc->LoadFile(path))
{
MessageBox(0, R"(InValid Path)", R"(BiMass)", 0);
}
TiXmlElement* root = doc->RootElement();
TiXmlElement* next = root->FirstChildElement();
parentNode = root->Value();
childNode = next->Value();
}
inline void ReadXML::GetXMLData()
{
cout << "uuuu" << endl;
}