引入模块
![](https://img-blog.csdnimg.cn/direct/cedeb15994cf45aa946012b5930c7108.png)
读标签内容
![](https://img-blog.csdnimg.cn/direct/e15d4107e3c64e2899cf497bfe24a1ea.png)
#include <XmlParser/Public/XmlFile.h>
void AUECPPGameModeBase::ReadXml()
{
//解析 xml
TSharedPtr<FXmlFile> XmlFile = MakeShareable(new FXmlFile);
//解析磁盘文件
if (XmlFile->LoadFile(TEXT("C:\\Users\\pc\\Desktop\\Week\\xml.txt"))) {
FXmlNode* RootNode = XmlFile->GetRootNode();
//RootNode->GetTag(); //获取标签名称
UE_LOG(LogTemp, Error, TEXT("rootNode = %s"), *RootNode->GetTag());
TArray<FXmlNode*> Childrens = RootNode->GetChildrenNodes();
UE_LOG(LogTemp, Error, TEXT("%s"), *Childrens[0]->GetContent());
}
}
![](https://img-blog.csdnimg.cn/direct/b7ff4d39e4f646678a4e57b8469e08cb.png)
读标签属性
![](https://img-blog.csdnimg.cn/direct/f27cbb5f54204f3fbb6321bc13200738.png)
![](https://img-blog.csdnimg.cn/direct/d31102358d2042b9b2fd3251e83f9fb5.png)
写
![](https://img-blog.csdnimg.cn/direct/45cca2697b3e4a4f9c84d15dcaf2fd61.png)
![](https://img-blog.csdnimg.cn/direct/d0f164c6692e4e24bf38786214d3b83d.png)