搜索文件的特定位置
Search specific position of file
我正在使用XMLReader,所以我想在XML文件中的标签之间阅读,但是我不知道如何读取文件中的特定位置?有建议吗?到目前为止,我要做的是:
#pragma once
#include<iostream>
#include<string>
#include<iostream>
#include<fstream>
#include<vector>
using namespace std;
class XmlReader
{
public:
void Read(ifstream &Read, string searchWord,int args)
{
string line = "";
string endline = "";
string OptionLine = "";
char array[100];
bool isXml=false;
while (!Read.eof())
{
string firstSearchWord = "<" + searchWord + ">";
string endSearchWord = "</" + searchWord + ">";
cout << line;
if (line.find(firstSearchWord) && line.find(endSearchWord))
{
}
}
}
};
这个只是很好的标签并正确的语法,我不知道如何在它们之间阅读。我想从中读到的示例是: <Gun1>Speed=100,Power=20,Ammo=50</Gun1>
谢谢..!
通过XML搜索将其视为常规字符串不是一个好主意。XML可能包含您不会忽略的评论XML,或者可能会检查的CDATA
部分。
最好的选择是使用适当的XML解析器处理XML Xerces-C 是这种事情的好候选者。
相关文章:
- 将值指定给向量(2D)的向量中的某个位置
- 使用Unreal C++获取VR耳机的世界位置/方向
- 写入位置0x0000000C时发生访问冲突
- 如何将两个不同矢量的同一位置的两个元素组合在一起
- GL_SHADERSTORAGE_BUFFER位置是否与其他着色器位置冲突
- 如何使用cudaMallocManaged在指针位置初始化对象?(C++)
- 无法获取webot::PositionSensor对象中位置传感器的值
- 非常量变量只读位置的赋值
- 如何定义更改car类中car位置的方法
- 使用迭代器时如何访问对象在向量中的位置?
- 更改.cpp程序的输入文件中数据的位置会意外更改输出
- 求最大元素位置的分治算法
- 你好。。。id_public变量不应该给出结果为 81 和 86 吗?为什么它为两个派生类占用不同的内存位置?
- 是与初始类同一内存位置的重新定位类
- 如何在使用网格布局时重叠qwidgets,并将重叠的widget定位在距离窗口边界特定距离的位置
- 我不知道如何定位最高随机数的位置
- 如何在MFC上设置窗口位置以将其定位到屏幕顶部
- 将QGraphicsSvgItem的中心定位在一个位置上。
- 如何定位WinRT异步方法调用中出现错误的位置
- 重定位表项在平面二进制文件中的存储位置