使用tinyxml解析器不能正常读取文件
我从网上下了一个tinyxml的解析代码文件,在其基础上编写了一个读取XML的类CXMLHelper。
起初在当前工程路径下创建了一个文件夹data在data目录下创建了station文件夹。在路径“..\data\stations\”下则是所有的一个站的所有xml文件。其中相关函数如下
TiXmlDocument* CXMLHelper::CreateXMLDocument(CString fileName)
{
TiXmlDocument* myDocument = NULL;
CString file;// 文件全称
// 获得当前工程路径
static CString currentPath="";
if(currentPath == "")
{
GetCurrentDirectory(MAX_PATH,currentPath.GetBuffer(MAX_PATH));
currentPath.ReleaseBuffer();
}
m_FilePath = currentPath +"\\data\\stations\";
// 根据文件名形成XML文件
file.Format("%s.xml",fileName);
m_FilePath += file;
// 根据XML文件创建文档对象
myDocument = new TiXmlDocument();
BOOL existed = myDocument->LoadFile(m_FilePath);
。。。。。。。
return myDocument;
}
TiXmlDocument* CXMLHelper::CreateXMLDocument(CString fileName)
{
TiXmlDocument* myDocument = NULL;
CString file;// 文件全称
// 获得当前工程路径
static CString currentPath="";
if(currentPath == "")
{
GetCurrentDirectory(MAX_PATH,currentPath.GetBuffer(MAX_PATH));
currentPath.ReleaseBuffer();
}
m_FilePath = currentPath +"\\data\\stations\"+fileName+"\";
// 根据文件名形成XML文件
file.Format("%s.xml",fileName);
m_FilePath += file;
// 根据XML文件创建文档对象
myDocument = new TiXmlDocument();
BOOL existed = myDocument->LoadFile(m_FilePath);
。。。。。。。
return myDocument;
}