|
is this code working at visual studio 2015 community ?
|
|
|
|
|
Trying to compile. Fixed some errors but still got these:
<pre lang="text">1> XMLite.cpp
1>XMLite.cpp(295): warning C4244: 'initializing': conversion from '__int64' to 'int', possible loss of data
1>XMLite.cpp(1424): error C2440: 'return': cannot convert from 'int' to 'std::_Vector_iterator<std::_Vector_val<std::_Simple_types<_tagXMLNode *>>>'
1> XMLite.cpp(1424): note: No constructor could take the source type, or constructor overload resolution was ambiguous
1>XMLite.cpp(1470): error C2451: conditional expression of type 'std::_Vector_iterator<std::_Vector_val<std::_Simple_types<_tagXMLNode *>>>' is illegal
1> XMLite.cpp(1470): note: No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
1>XMLite.cpp(1512): error C2440: 'return': cannot convert from 'int' to 'std::_Vector_iterator<std::_Vector_val<std::_Simple_types<_tagXMLAttr *>>>'
1> XMLite.cpp(1512): note: No constructor could take the source type, or constructor overload resolution was ambiguous
1>XMLite.cpp(1543): error C2451: conditional expression of type 'std::_Vector_iterator<std::_Vector_val<std::_Simple_types<_tagXMLAttr *>>>' is illegal
1> XMLite.cpp(1543): note: No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
1>XMLite.cpp(1612): error C2451: conditional expression of type 'std::_Vector_iterator<std::_Vector_val<std::_Simple_types<_tagXMLNode *>>>' is illegal
1> XMLite.cpp(1612): note: No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
1>XMLite.cpp(1632): error C2451: conditional expression of type 'std::_Vector_iterator<std::_Vector_val<std::_Simple_types<_tagXMLAttr *>>>' is illegal
1> XMLite.cpp(1632): note: No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
1>XMLite.cpp(1790): warning C4244: 'return': conversion from '__int64' to 'int', possible loss of data
1>XMLite.cpp(1815): warning C4244: 'return': conversion from '__int64' to 'int', possible loss of data
1>XMLite.cpp(1823): warning C4267: 'initializing': conversion from 'size_t' to 'int', possible loss of data
1>XMLite.cpp(1839): warning C4267: 'initializing': conversion from 'size_t' to 'int', possible loss of data
</pre>
|
|
|
|
|
I found further down some help with this. Now have these warnings:
<pre lang="text">1>XMLite.cpp(295): warning C4244: 'initializing': conversion from '__int64' to 'int', possible loss of data
1>XMLite.cpp(1792): warning C4244: 'return': conversion from '__int64' to 'int', possible loss of data
1>XMLite.cpp(1817): warning C4244: 'return': conversion from '__int64' to 'int', possible loss of data
1>XMLite.cpp(1825): warning C4267: 'initializing': conversion from 'size_t' to 'int', possible loss of data
1>XMLite.cpp(1841): warning C4267: 'initializing': conversion from 'size_t' to 'int', possible loss of data
</pre>
|
|
|
|
|
Hello,
Why using the CPOL license ? This license is not a free software license and has several restrictions :
https://www.gnu.org/licenses/license-list.en.html
"You agree not to use the Work for illegal, immoral or improper purposes, or on pages containing illegal, immoral or improper material."
"You agree not to sell, lease, or rent any part of the Work."
You should use a GNU GPL license or Apache license or another free software license instead.
|
|
|
|
|
I finally had time to get the xml output properly formatted.
I had a save and a load function and was constantly re-parsing the saved xml. Discovered that linebreaks were accumulated after each end tag. There were also two ugly empty lines at the start of the document. Try the following changes to _tagXMLNode::GetXML for a prettier output:
AFX_EXT_API CString _tagXMLNode::GetXML( LPDISP_OPT opt )
{
std::ostringstream os;
if( type != XNODE_DOC && type != XNODE_PI && opt && opt->newline )
{
...
...
if( value != _T("") )
{
if( opt && opt->newline && !childs.empty() )
{
int i;
}
os << (LPCTSTR)(opt->reference_value&&opt->entitys?opt->entitys->Entity2Ref(value):value);
}
if( opt && opt->newline && !childs.empty() )
{
int i;
}
os << "</" << (LPCTSTR)name << '>';
...
...
}
Here are my save and load functions for completeness:
AFX_EXT_API LPTSTR _tagXMLDocument::LoadFile( LPCTSTR pszFilename, LPPARSEINFO pi )
{
CFile xmlf;
LPTSTR lptstrRet = NULL;
if (xmlf.Open(pszFilename, CFile::modeRead))
{
DWORD l = (DWORD)xmlf.GetLength();
char *xmlbuffer = new char[l+1];
xmlbuffer[l] = '\0';
TRY
{
xmlf.Read(xmlbuffer, l);
lptstrRet = Load(xmlbuffer, pi);
}
CATCH(CFileException, e)
{
CString csErr = "Error reading '" + pszFilename + "'";
AfxMessageBox(csErr , MB_ICONSTOP);
}
END_CATCH
xmlf.Close();
delete xmlbuffer;
}
return lptstrRet;
}
AFX_EXT_API BOOL _tagXMLDocument::SaveFile(LPCTSTR pszFilename, LPDISP_OPT opt )
{
CFile xmlf;
if (xmlf.Open(pszFilename, CFile::modeWrite|CFile::modeCreate))
{
TRY
{
CString csXML = GetXML(opt);
xmlf.Write(csXML, csXML.GetLength());
}
CATCH(CFileException, e)
{
CString csErr = "Error saving '" + pszFilename + "'";
AfxMessageBox(csErr , MB_ICONSTOP);
xmlf.Close();
return FALSE;
}
END_CATCH
xmlf.Close();
return TRUE;
}
return FALSE;
}
Edit: Another small bug... Change
pi->error_string.Format(_T("%s must be closed with </%s>"), name );
to
pi->error_string.Format(_T("%s must be closed with </%s>"), name, name );
modified 17-Jun-14 16:03pm.
|
|
|
|
|
I am study some kind of XML learning, and try to make a XML parsing program.
It is helpful . Good Job!
|
|
|
|
|
Great job on software.
Have you ever attempted to compile with Vusal Studio 2008? I am running into errors with _c:\temp\xmlite_demo\xmlite.cpp(1425) : error C2664: 'std::_Vector_iterator<_Ty,_Alloc>::_Vector_iterator(const std::_Vector_iterator<_Ty,_Alloc> &)' : cannot convert parameter 1 from 'int' to 'const std::_Vector_iterator<_Ty,_Alloc> &'
1> with
1> [
1> _Ty=LPXNode ,
1> _Alloc=std::allocator<LPXNode >
1> ]
1> Reason: cannot convert from 'int' to 'const std::_Vector_iterator<_Ty,_Alloc>'
1> with
1> [
1> _Ty=LPXNode ,
1> _Alloc=std::allocator<LPXNode >
1> ]
Any suggestions?
|
|
|
|
|
see infosarang's post from Feb 2009.
|
|
|
|
|
Firstly I would like to tell you that I believe you have done a great job with this project. I particulary find it very useful.
My question is the following one:
In some cases, I need to create a XLM string containing a XML struct. I create the XML nodes and at the end get the string through GetXML(). I get the xml string correctly but containig "⎡" characters.
In some cases, this is very useful( when creating a file, it includes directly the tabs and carriage returns needed). But in some other cases, I would like to eliminate this part.
I mean, for example for the following struct generated:
<TAddressBook description='book of bro' >
<TPerson type='friend' >
<Name>Baik,Ji Hoon</Name>
<Nick>bjh</Nick>
</TPerson>
<TPerson type='friend' >
<Name>Bak,Gun Joo</Name>
<Nick>dichter</Nick>
</TPerson>
<TInformation count='3' />
</TAddressBook>
Insteado of obtaining something like this when calling GetXML()
<TAddressBook description='book of bro' >⎡⎡<TPerson type='friend' >⎡⎡⎡⎡⎡<Name>Baik,Ji⎡⎡⎡⎡⎡Hoon</Name>⎡⎡⎡⎡⎡<Nick>bjh</Nick>⎡⎡⎡⎡⎡</TPerson>⎡⎡⎡⎡⎡<TPerson type='friend' >⎡⎡⎡⎡⎡<Name>Bak,Gun Joo</Name>⎡⎡⎡⎡⎡<Nick>dichter</Nick>⎡⎡⎡⎡⎡</TPerson>⎡⎡⎡⎡⎡<TInformation count='3' />⎡⎡⎡⎡⎡</TAddressBook>
Get something like this:
<TAddressBook description='book of bro' ><TPerson type='friend' ><Name>Baik,Ji Hoon</Name><Nick>bjh</Nick></TPerson><TPerson type='friend' ><Name>Bak,Gun Joo</Name><Nick>dichter</Nick></TPerson><TInformation count='3' /></TAddressBook>
Many thanks in advance for your help
|
|
|
|
|
There is a pure C version of this XML parser? if no, is it easy to do so?
|
|
|
|
|
First, I thanks Cho, Kyung-min for this great class!
The program I build needed a parser to read a hierarhic XML file. With XMLite I can do that job. The problem is that my program is a real UNICODE application. To link in the module I have done the UNICODE conversion.
My program a UNICODE C++/MFC application running on Windows 7 which is maintained with MSVC++ 6.0 updated with the last SP's and API-libs.
The class is using the TCHAR, LPTSTR and LPCTSTR macro definitions.
It also uses the _T( ) macro for some strings but not all of them.
When using those macros, you need to recalculate the character size because in UNICODE the size of a string in bytes is not the same as the character count.
So, here is a list of what I have changed:
1. Change all literal strings from "xxxx" into _T("xxxx")
2. Change all literal chars from 'x' into _T('x')
3. Change all sizeof(szXMLPIOpen)-1 into sizeof(szXMLPIOpen)/sizeof(TCHAR)-1
4. Change all sizeof(szXMLPIClose)-1 into sizeof(szXMLPIClose)/sizeof(TCHAR)-1
5. Change all sizeof(szXMLCDATAOpen)-1 into sizeof(szXMLCDATAOpen)/sizeof(TCHAR)-1
6. Change all sizeof(szXMLCDATAClose)-1 into sizeof(szXMLCDATAClose)/sizeof(TCHAR)-1
7. Change all sizeof(szXMLCommentOpen)-1 into sizeof(szXMLCommentOpen)/sizeof(TCHAR)-1
8. Change all sizeof(szXMLCommentClose)-1 into sizeof(szXMLCommentClose)/sizeof(TCHAR)-1
9. Change all memcpy( pss, psz, len ); into memcpy( pss, psz, len * sizeof(TCHAR) );
10. Change all strchr into _tcschr
11. Change all std::ostringstream os; into std::basic_ostringstream<TCHAR> os;
These macro's make it possible to compile for ANSI or UNICODE.
What left are the settings for the preprocessor, compiler and linker.
Setup Win32 Unicode Release for VC++6.0:
Click on build->configurations.
Click add.
Type in configuration: Unicode Release.
Select in copy settings from: <project> - Win32 Release.
Click ok and close
Click on project-settings.
Select in settings for: Win32 Unicode Release.
Click on tab General.
Change content of output directories into Unicode_Release.
Change content of output files into Unicode_Release.
Click on tab C/C++.
Select category: general.
change in Preprocessor definitions _MBCS into _UNICODE,UNICODE.
Click on tab Link.
Select category: Output.
Type in Entry-point symbol: wWinMainCRTStartup.
Click on OK.
Setup Win32 Unicode Debug for VC++6.0:
Click on build->configurations.
Click add.
Type in configuration: Unicode Debug.
Select in copy settings from: <project> - Win32 Debug.
Click ok and close
Click on project-settings.
Select in settings for: Win32 Unicode Debug.
Click on tab General.
Change content of output directories into Unicode_Debug.
Change content of output files into Unicode_Debug.
Click on tab C/C++.
Select category: general.
change in Preprocessor definitions _MBCS into _UNICODE,UNICODE.
Click on tab Link.
Select category: Output.
Type in Entry-point symbol: wWinMainCRTStartup.
Click on OK.
If this can help you, please drop a line...
modified on Wednesday, April 7, 2010 4:47 AM
|
|
|
|
|
Remove the locally recreated object - attrs.
Priya Sundar
|
|
|
|
|
There is no bug!
The object attrs is automatic. When it goes out of scope, it calls the vector destructor to clear all used memory. Only if you put a pointer to allocated memory into the vector, then that memory must be deleted before calling the destructor.
|
|
|
|
|
Hello,
I am looking for the unicode version of the xmlite parser.
I went through the mailing list and tried suggested changes.
But its not working on Windows Vista using VS2008.
Pl let me know the pointer.
Thanks
G.Muruganandam
|
|
|
|
|
|
<A>
<B>
<C>
<1/>
<2/>
<3/>
</C>
</B>
</A>
Your example shows that control 3 deeps childs
I want to know that it possible to control child over 5 deeps
thanks.
|
|
|
|
|
hi, zzigee.
XMLite hasn't no limitation about deepth.
You can easily grow the deepth of tree by using AppendChild on child node recursively.
Thank you all. No one know oneself all. My idea from you, book, all others. already we are shared brains.
|
|
|
|
|
Hi,
I used XMLite in both VS2002 and VS 2005 with MFC, and now i goes with Windows CE version. Can any one used XMLite under Win CE version, then what are the necessary to change for Win CE....?
Help Needed,
Thanks in advance,
-Saran.
|
|
|
|
|
using code::blocks 8.02, GNU GCC compiler.
I get the following errors (after removing line 5 from XMLite.cpp (#include "stdafx.h"), which is a microsoft only header?
Any idea what I can do to get this to compile?
errors in XMLite.h
------------------
C:\Program Files\CodeBlocks\XMLite\XMLite.h|57|error: `LPTSTR' has not been declared|
C:\Program Files\CodeBlocks\XMLite\XMLite.h|57|error: ISO C++ forbids declaration of `entity' with no type|
C:\Program Files\CodeBlocks\XMLite\XMLite.h|57|error: `_tagXmlEntity* _tagXMLEntitys::GetEntity(int)' and `_tagXmlEntity* _tagXMLEntitys::GetEntity(int)' cannot be overloaded|
C:\Program Files\CodeBlocks\XMLite\XMLite.h|58|error: `LPCTSTR' has not been declared|
C:\Program Files\CodeBlocks\XMLite\XMLite.h|58|error: ISO C++ forbids declaration of `str' with no type|
C:\Program Files\CodeBlocks\XMLite\XMLite.h|59|error: `LPCTSTR' has not been declared|
C:\Program Files\CodeBlocks\XMLite\XMLite.h|59|error: `LPTSTR' has not been declared|
C:\Program Files\CodeBlocks\XMLite\XMLite.h|59|error: ISO C++ forbids declaration of `estr' with no type|
C:\Program Files\CodeBlocks\XMLite\XMLite.h|59|error: ISO C++ forbids declaration of `str' with no type|
C:\Program Files\CodeBlocks\XMLite\XMLite.h|60|error: `LPCTSTR' has not been declared|
C:\Program Files\CodeBlocks\XMLite\XMLite.h|60|error: `LPTSTR' has not been declared|
C:\Program Files\CodeBlocks\XMLite\XMLite.h|60|error: ISO C++ forbids declaration of `str' with no type|
C:\Program Files\CodeBlocks\XMLite\XMLite.h|60|error: ISO C++ forbids declaration of `estr' with no type|
C:\Program Files\CodeBlocks\XMLite\XMLite.h|61|error: `CString' does not name a type|
C:\Program Files\CodeBlocks\XMLite\XMLite.h|62|error: `CString' does not name a type|
C:\Program Files\CodeBlocks\XMLite\XMLite.h|68|error: `CString' does not name a type|
C:\Program Files\CodeBlocks\XMLite\XMLite.h|69|error: `CString' does not name a type|
C:\Program Files\CodeBlocks\XMLite\XMLite.h|89|error: `LPTSTR' does not name a type|
C:\Program Files\CodeBlocks\XMLite\XMLite.h|91|error: `LPTSTR' does not name a type|
C:\Program Files\CodeBlocks\XMLite\XMLite.h|93|error: `CString' does not name a type|
and so on.. (50 errors all up)
thanks
|
|
|
|
|
I also tested the XMLite using gcc compiler i also gets more no. errors. don't know how to rectify this
|
|
|
|
|
|
hello,
i must say, that using Your xml parser is far more comfortable than using msxml. thank You for Your time and efforts.
nonetheless, it stroke me down, when i've noticed the number of compiler errors related to unicode compatibility (tchar.h stuff). i suggest You to pay more attention to _T() macro. otherwise, Your code simply doesn't compile.
cheers,
malleor
|
|
|
|
|
there's NO unicode version on the 'net and changes needed to be made are time-consuming. You do use _T sometimes, but generally Your code is not unicode-consious. many operations assuming sizeof(tchar)=1 result in baaad parsing.
i see work to be done. mine, unfortunately.
cheers
|
|
|
|
|
nice job,thanks for all your sharing.
|
|
|
|
|
Hi,
When i use XMLite in VC++ 2002 its works fine, but when i switch to VC++ 2005, it produces 6 errors,
std::_Vector_iterator<_Ty,_Alloc>::_Vector_iterator(const std::_Vector_iterator<_Ty,_Alloc> &)' : cannot convert parameter 1 from 'int' to 'const std::_Vector_iterator<_Ty,_Alloc> &'
with
[
_Ty=LPXNode ,
_Alloc=std::allocator<lpxnode>
]
Reason: cannot convert from 'int' to 'const std::_Vector_iterator<_Ty,_Alloc>'
with
[
_Ty=LPXNode ,
_Alloc=std::allocator<lpxnode>
]
No constructor could take the source type, or constructor overload resolution was ambiguous
</lpxnode></lpxnode>
I doesn't know the Iterator return NULL but its not supported as XNodes::iterator???
Thanks,
Saran.
|
|
|
|
|