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

  1. Visual Studio 2022
  2. tinyxml, download link: TinyXML

Steps

  1. 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.
  2. According to the downloaded package, open it with visual studio, and create a new configuration manager, create x64 configuration in it, then compile the tinyxml project file. You can compile Debug, Release versions at once.
    Image Description
  3. After generation, put the following files into the folder for later reference/quotation
    Image Description

Image Description
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.

1
#pragma comment(lib,"D:\\C++ Programming\\MFCAutoUpdateApplication\\src\\tinyxml\\lib\\debug\\tinyxml.lib")
  1. Below is a code example, concatenating to MFC to display node name
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#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;
}