CMarkup XML CString
#include "Markup.h"
#include <iostream>
#include <string>
using namespace std;
int main()
{
CMarkup xml;
MCD_STR XML_Address = "UserInfo.xml";
MCD_STR XML_Head = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n";
MCD_STR XML_UserInfo = "UserInfo";
MCD_STR XML_UserID = "UserID";
//1.创建XML
/*MCD_STR XML_IDValue1 = "luo";
MCD_STR XML_IDValue2 = "lin";
xml.SetDoc(XML_Head);
xml.AddElem(XML_UserInfo);
xml.IntoElem();
xml.AddElem(XML_UserID,XML_IDValue1);
xml.AddElem(XML_UserID,XML_IDValue2);
xml.OutOfElem();
xml.Save(XML_Address);*/
//2.解析XML
string tagName;
string data;
xml.Load(XML_Address );
BOOL bFind = true;
xml.ResetMainPos();
while(xml.FindChildElem(XML_UserID))
{
//此时接点还是父接点
CString strTagName ;
CString strData ;
strTagName = xml.GetChildTagName();
strData = xml.GetChildData();
tagName = strTagName.GetBuffer(0);//此处出现问题
data = strData.GetBuffer(0);//此处出现问题
cout<<"tagName = "<<tagName<<",data = "<<data<<endl;
}
while(1);
return 0;
}
问题如下:
e:\base\code\xml\tempxmltest1\tempxmltest1\test.cpp(43) : error C2679: binary '=' : no operator found which takes a right-hand operand of type 'wchar_t *' (or there is no acceptable conversion)
1> c:\program files\microsoft visual studio 9.0\vc\include\xstring(914): could be 'std::basic_string<_Elem,_Traits,_Ax> &std::basic_string<_Elem,_Traits,_Ax>::operator =(const std::basic_string<_Elem,_Traits,_Ax> &)'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>,
1> _Ax=std::allocator<char>
1> ]
1> c:\program files\microsoft visual studio 9.0\vc\include\xstring(919): or 'std::basic_string<_Elem,_Traits,_Ax> &std::basic_string<_Elem,_Traits,_Ax>::operator =(const _Elem *)'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>,
1> _Ax=std::allocator<char>
1> ]
1> c:\program files\microsoft visual studio 9.0\vc\include\xstring(924): or 'std::basic_string<_Elem,_Traits,_Ax> &std::basic_string<_Elem,_Traits,_Ax>::operator =(_Elem)'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>,
1> _Ax=std::allocator<char>
1> ]
1> while trying to match the argument list '(std::string, wchar_t *)'
1>e:\base\code\xml\tempxmltest1\tempxmltest1\test.cpp(44) : error C2679: binary '=' : no operator found which takes a right-hand operand of type 'wchar_t *' (or there is no acceptable conversion)
1> c:\program files\microsoft visual studio 9.0\vc\include\xstring(914): could be 'std::basic_string<_Elem,_Traits,_Ax> &std::basic_string<_Elem,_Traits,_Ax>::operator =(const std::basic_string<_Elem,_Traits,_Ax> &)'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>,
1> _Ax=std::allocator<char>
1> ]
1> c:\program files\microsoft visual studio 9.0\vc\include\xstring(919): or 'std::basic_string<_Elem,_Traits,_Ax> &std::basic_string<_Elem,_Traits,_Ax>::operator =(const _Elem *)'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>,
1> _Ax=std::allocator<char>
1> ]
1> c:\program files\microsoft visual studio 9.0\vc\include\xstring(924): or 'std::basic_string<_Elem,_Traits,_Ax> &std::basic_string<_Elem,_Traits,_Ax>::operator =(_Elem)'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>,
1> _Ax=std::allocator<char>
1> ]
1> while trying to match the argument list '(std::string, wchar_t *)'
1>Generating Code...
1>Build log was saved at "file://e:\base\code\XML\tempXMLtest1\tempXMLtest1\Debug\BuildLog.htm"
1>tempXMLtest1 - 2 error(s), 0 warning(s)