小编dif*_*ent的帖子

C++使用STD解析XML

我知道有几个XML libaries在那里,但不幸的是,我无法用它们来我工作的学校项目.

我有一个创建此XML文件的程序.

<theKey>
<theValue>23432</theValue>
</theKey>
Run Code Online (Sandbox Code Playgroud)

我想要做的是解析标签之间的"23432".但是,文件中有随机标记,因此可能并不总是位于顶部的第二行.另外,我不知道标签之间的数字是多少位数.

这是我到目前为止开发的代码.它是基本的,因为我不知道我可以使用哪些是将解析值的C++语言的一部分.我在使用JAVA时的暗示是使用"字符串"库中的某些东西,但到目前为止,我对我可以使用的东西很缺乏.

任何人都可以给我指导或线索我可以做什么/使用什么?非常感谢.

这是我到目前为止开发的代码:

#include <iostream>
#include <fstream>
#include <string>

using std::cout;
using std::cin;
using std::endl;
using std::fstream;
using std::string;
using std::ifstream;


int main()
{
 ifstream inFile;
 inFile.open("theXML.xml");

 if (!inFile)
 {
 }

 string x;
 while (inFile >> x)
 {
  cout << x << endl;
 }

 inFile.close();

 system ( "PAUSE" );


 return 0;
}
Run Code Online (Sandbox Code Playgroud)

c++ xml string parsing std

3
推荐指数
1
解决办法
1万
查看次数

标签 统计

c++ ×1

parsing ×1

std ×1

string ×1

xml ×1