|
We have chosen to stick with your current implementation for now.
Thanks
Ian
|
|
|
|
|
Anybody has this working on Visual Studio 2005?
|
|
|
|
|
XNodes::iterator _tagXMLNode::GetChildIterator( LPXNode node )<br />
{<br />
XNodes::iterator it = childs.begin();<br />
for( ; it != childs.end() ; ++(it) )<br />
{<br />
if( *it == node )<br />
return it;<br />
}<br />
return NULL; <br />
}<br />
|
|
|
|
|
you can find that fix in other's reply.
Thank you all. No one know oneself all. My idea from you, book, all others. already we are shared brains.
|
|
|
|
|
Good work. Yet I realize that this isn't a standard-compliant code. XMLite.cpp at line 330 throws me an error: 'i' undeclared identified. You have the following code:
for( int i = 0 ; i < childs.size(); i ++)
{
...
}
childs.clear();
for( i = 0 ; i < attrs.size(); i ++)
{
...
}
While compiling it with VC8 it throws me 7 errors and 17 warnings.
Regards.
Hope is the negation of reality - Raistlin Majere
|
|
|
|
|
You can download this http://download.svetla.org/download/XMLite.ZIP for your project. I´m using it for unicode too. I recommend substitute ->name for ->GetName().
Regards.
Jaroslav Nusl
www.svetla.org
|
|
|
|
|
My project is based and compiled with Unicode (VC2005). When I compile this excellent code I get some errors because of that (for example the use of strchr). Can someone know where to get a Unicode version.
Thanks,
Yossi.
|
|
|
|
|
Hi Yossi
I reached that it works for me with Unicode, VC2005.
I had to recreate a project as Unicode, and make some corrections...
Most important change types are listed:
* '<' -> _T('<'), " ?>" -> _T(" ?>"), etc in all similar cases
* sizeof(szXMLCDATAOpen) -> sizeof(szXMLCDATAOpen)/sizeof(TCHAR), and similar
* memcpy( pss, psz, len); ->
#ifdef _UNICODE
memcpy( pss, psz, 2*len);
#else
memcpy( pss, psz, len);
#endif
* if( strchr( pszchs, *psz ) ) return (LPTSTR)psz; ->
#ifdef _UNICODE
if( wcschr( pszchs, *psz ) ) return (LPTSTR)psz;
#else
if( strchr( pszchs, *psz ) ) return (LPTSTR)psz;
#endif
* std::ostringstream os; ->
#ifdef _UNICODE
std::wostringstream os;
#else
std::ostringstream os;
#endif
There are also many changes to address warnings.
If you like, I could send to you my version, or put it in some public place, please instruct.
AlexandreN
|
|
|
|
|
If you would care to share your Unicode version that'd be great ! Judging by the number of errors I get it sounds quite a big task, especially with regard to std::string which appears to be 'char' based regardless of whether you are compiling UNICODE or not (or have I missed something) ???
TTFN,
Jon
|
|
|
|
|
I would gladly share, if somebody explained me the best practice how to share.
Alexandre
|
|
|
|
|
Hi Alexandre,
I'm not sure best way to share. If you get stuck I can temporarily host them on my website so othres can download them, at least until a better solution is found.
TTFN,
Jon
PS : I tried to reply to your email address but it bounced ....
|
|
|
|
|
Jon,
I am looking for Unicode version of XMLlite. Hi can you post Unicode version of XMLLite ?
|
|
|
|
|
Love xmlite so far but ran into a problem today trying to parse the document.xml file found in the .docx zip file (Word2007 document file). In the .xml file, there are 12 tags with the name "w:p". After parsing, xmlite shows only one w:p tag. I am using the xmlite download from Creative Commons.
I am a complete novice at xml and xmlite, so I may be committing some obviously stupid mistake. However, everything I have parsed prior to this file has acted as expected and thus I don't know why this doesn't act the same. Any ideas?
I have attached the document.xml file below.
thanks for any help you might provide.
<w:document xmlns:ve="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns ="urn:schemas-microsoft-com:office:office" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:m="http://schemas.openxmlformats.org/officeDocument/2006/math" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:wp="http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing" xmlns:w10="urn:schemas-microsoft-com:office:word" xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main" xmlns:wne="http://schemas.microsoft.com/office/word/2006/wordml"><w:body><w:p w:rsidr="001671DB" w:rsidrdefault="00265A14" w:rsidp="00265A14"><w:ppr><w:pstyle w:val="Heading1"><w:r><w:t>Heading 1<w:p w:rsidr="00265A14" w:rsidrdefault="00265A14" w:rsidp="00265A14"><w:r><w:t>Heading 1 normal text<w:p w:rsidr="00265A14" w:rsidrdefault="00265A14" w:rsidp="00265A14"><w:ppr><w:rpr><w:b><w:r w:rsidrpr="00265A14"><w:rpr><w:b><w:t>Bold Text<w:p w:rsidr="00265A14" w:rsidrdefault="00265A14" w:rsidp="00265A14"><w:ppr><w:rpr><w:i><w:r w:rsidrpr="00265A14"><w:rpr><w:i><w:t>Italics Text<w:p w:rsidr="00265A14" w:rsidrdefault="00265A14" w:rsidp="00265A14"><w:ppr><w:rpr><w:b><w:i><w:r w:rsidrpr="00265A14"><w:rpr><w:b><w:i><w:t>Bold Italics Text<w:p w:rsidr="00A424D9" w:rsidrpr="00A424D9" w:rsidrdefault="00A424D9" w:rsidp="00265A14"><w:r><w:t xml:space="preserve">This is a long run of normal text to show how multiple lines are treated in a single run of really long <w:r w:rsidr="009228BE"><w:t xml:space="preserve">skinny tall short fat light <w:r><w:t>long text.<w:p w:rsidr="00265A14" w:rsidrdefault="00265A14" w:rsidp="00265A14"><w:ppr><w:pstyle w:val="Heading2"><w:r><w:t>Heading2<w:p w:rsidr="00265A14" w:rsidrdefault="00265A14" w:rsidp="00265A14"><w:r><w:t>Heading2 normal text<w:p w:rsidr="00265A14" w:rsidrdefault="00265A14" w:rsidp="00265A14"><w:ppr><w:pstyle w:val="Heading3"><w:r><w:t>Heading 3<w:p w:rsidr="00265A14" w:rsidrdefault="00265A14" w:rsidp="00265A14"><w:r><w:t>Heading 3 normal text<w:p w:rsidr="00265A14" w:rsidrdefault="00265A14" w:rsidp="00265A14"><w:p w:rsidr="00265A14" w:rsidrpr="00265A14" w:rsidrdefault="00265A14" w:rsidp="00265A14"><w:sectpr w:rsidr="00265A14" w:rsidrpr="00265A14" w:rsidsect="001671DB"><w:pgsz w:w="12240" w:h="15840"><w:pgmar w:top="1440" w:right="1440" w:bottom="1440" w:left="1440" w:header="720" w:footer="720" w:gutter="0"><w:cols w:space="720"><w:docgrid w:linepitch="360">
|
|
|
|
|
http://www.cogniview.com/creative-commons-info.php[^]
Creative Commons Information Acrobat Plugin (CCInfo), cogniview project uses XMLite. thanks for using. and He updates XMLite for VS2005.
and. His project is opensource.
Thank you.
Thank you all. No one know oneself all. My idea from you, book, all others. already we are shared brains.
|
|
|
|
|
This is just what i was looking for! Its a great little library and now it compiles cleanly in VS2005!
Would it be possible to update the article with the latest sourcecode from Creative Commons?
Ive given you a 5!
|
|
|
|
|
very usefull!!!!
Best regards
Klaus
|
|
|
|
|
hi
I would need your help
I working on a application in C++ using visual studio 2005 and the mfc
I figured out that the program I want to right would work pretty well with a xml file, I've used it breifly in flash for somthing similar so I know it meet my needs
my problem is I don't know how to do it in c++
I tried this program but I get theis errors
c:\documents and settings\jsr\desktop\xmlite.cpp(1424) : 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> ]
1> No constructor could take the source type, or constructor overload resolution was ambiguous
1>c:\documents and settings\jsr\desktop\xmlite.cpp(1470) : error C2451: conditional expression of type 'std::_Vector_iterator<_Ty,_Alloc>' is illegal
1> with
1> [
1> _Ty=LPXNode ,
1> _Alloc=std::allocator<lpxnode>
1> ]
1> No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
1>c:\documents and settings\jsr\desktop\xmlite.cpp(1490) : warning C4018: '<' : signed/unsigned mismatch
I just need a simple class to write and read the content of an xml file
can you explain me or indicate me a class that does it simply, I don't need performance or speed.
I liked this program a lot because it seems to give an application of what your class with the buttons
can you help me out please
|
|
|
|
|
Have a look on the topic bellow "It doesn't compiles with MS VC++ 2005"
|
|
|
|
|
Is there anyway I can add an attribute for one of the node? I see you have CreateAttr but how to use it for one of the node I want?
For example, I have:
<SUB>
<ID>
<NAME>Joe</NAME>
</ID>
<ID>
<NAME>Owen</NAME>
</ID>
</SUB>
And I want to add an attribute to the second ID to become as follow:
<SUB>
<ID>
<NAME>Joe</NAME>
</ID>
<ID Identity = "first">
<NAME>Owen</NAME>
</ID>
</SUB>
Thanks in advance!
|
|
|
|
|
you can use AppendAttr. (CreateAttr is just return created XAttr)
if you want to create right now, and append someday.
then you can seperate operation of AppendAttr.
LPXAttr pAttr = AnyNode.CreateAttr("identity", "first");
...
WantNode.AppendAttr(pAttr);
BUT, DONT reuse pAttr like below.
WantNode2.AppendAttr(pAttr);
then XMLite's destructor lost work. (dangling pointer problem will be occur on Close() )
void CTestXMLiteDlg::OnButton14()
{
// TODO: Add your control notification handler code here
CString sXML = "\
<SUB>\
<ID>\
<NAME>Joe</NAME>\
</ID>\
<ID>\
<NAME>Owen</NAME>\
</ID>\
</SUB>\
";
XNode node;
if( node.Load( sXML ) )
{
AfxMessageBox( node.GetXML() );
LPXNode found = NULL;
found = node.Find( _T("ID") );
if( found )
{
XNodes IDs = found->parent->GetChilds("ID");
IDs[1]->AppendAttr("identity", "first");
AfxMessageBox( node.GetXML() );
}
}
}
Thank you all. No one know oneself all. My idea from you, book, all others. already we are shared brains.
|
|
|
|
|
Thank you very much, Kyung-Min. You have been very helpful and XMLite is really a good one, can be used for many purposes. Thanks a lot!
|
|
|
|
|
One more question, if I have this:
CString sXML = "\
<SUB>\
<ID>\
<NAME>Joe</NAME>\
</ID>\
<ID>\
<NAME>Owen</NAME>\
</ID>\
</SUB>\
";
XNode node;
if( node.Load( sXML ) )
{
AfxMessageBox( node.GetXML() );
}
Whenever it is displayed, why it will create a single space (sometimes double space) before each closing tag? For example the code above will become:
<SUB>
<ID>
<NAME>Joe</NAME>
</ID>
<ID>
<NAME>Owen</NAME>
</ID>
</SUB>
I am writing it into a file. So when it comes up in the file, it create squares in between those space. It would be great if this can be fixed. It also happened when we use LoadFromFile, though in the original file, it doesn't show the single spaces.
Thanks.
|
|
|
|
|
yes it's bug.
you can fix it easily
void _SetString( LPTSTR psz, LPTSTR end, CString* ps, bool trim = FALSE, int escape = 0 )
{
//trim
if( trim )
{
while( psz && psz < end && _istspace(*psz) ) psz++;
while( (end-1) && psz < (end-1) && _istspace(*(end-1)) ) end--;
}
int len = end - psz;
if( len <= 0 ) return;
if( escape )
{
len = _tcselen( escape, psz, end );
LPTSTR pss = ps->GetBufferSetLength( len );
_tcsecpy( pss, escape, psz, end );
}
else
{
LPTSTR pss = ps->GetBufferSetLength(len + 1 );
memcpy( pss, psz, len );
pss[len] = '\0';
}
// [BUGFIX] newline bug fix on GetXML()
if(XIsEmptyString(*ps))
ps->Empty();
}
Thank you all. No one know oneself all. My idea from you, book, all others. already we are shared brains.
|
|
|
|
|
Hi Kyung-Min,
I am impressed with you work on XMLite XML parser in CodeProject. I see you
are a very good programmer.
I am stuck with the program I am writing regarding XML. I am wondering if
you can help me.
I need to add a XML code onto another XML file. For example:
In MyXML.xml:
<SUBAPPLICATION>
<GRAPH>
<ID Identity="G1">
<NAME>Haptic Audio Graphs</NAME>
<GRAPHICTYPE>Graph</GRAPHICTYPE>
<GRAPHICFORMAT>XLS, SVG</GRAPHICFORMAT>
</ID>
</GRAPH>
<MAP>
<ID Identity="M1">
<NAME>Haptic Audio Maps</NAME>
<GRAPHICTYPE>Map</GRAPHICTYPE>
<GRAPHICFORMAT>DAU, GIS, GLM</GRAPHICFORMAT>
</ID>
</MAP>
</SUBAPPLICATION>
And I have another xml code (xml 2):
<GRAPH>
<ID Identity="G2">
<NAME>Haptic Graphs</NAME>
<GRAPHICTYPE>Graph</GRAPHICTYPE>
<GRAPHICFORMAT>XLS</GRAPHICFORMAT>
</ID>
</GRAPH>
So I need to place xml code in xml 2 into my MyXML.xml code. So if it is
<GRAPH>, then it needs to be put under <GRAPH>. If it is <MAP>, then it
needs to be put under <MAP>. So for the example above, the output should be:
In MyXML.xml:
<SUBAPPLICATION>
<GRAPH>
<ID Identity="G1">
<NAME>Haptic Audio Graphs</NAME>
<GRAPHICTYPE>Graph</GRAPHICTYPE>
<GRAPHICFORMAT>XLS, SVG</GRAPHICFORMAT>
</ID>
<ID Identity="G2">
<NAME>Haptic Graphs</NAME>
<GRAPHICTYPE>Graph</GRAPHICTYPE>
<GRAPHICFORMAT>XLS</GRAPHICFORMAT>
</ID>
</GRAPH>
<MAP>
<ID Identity="M1">
<NAME>Haptic Audio Maps</NAME>
<GRAPHICTYPE>Map</GRAPHICTYPE>
<GRAPHICFORMAT>DAU, GIS, GLM</GRAPHICFORMAT>
</ID>
</MAP>
</SUBAPPLICATION>
If you know what I mean, can you give me some helps how I can do that? I am
trying to see if I can use any of your method.
Look forward to hearing from you. Please help....
Many thanks,
-----------------------------------
here is my answer.
a.xml is first xml file.
b.xml is second xml file.
int LoadFromFile(char* fpath, char* buf)
{
FILE* fp;
fp = fopen(fpath, "rt");
if( fp == NULL)
return 0;
fread(buf, 1, 1000, fp );
fclose(fp);
return 1;
}
void CTestXMLiteDlg::OnButton13()
{
// TODO: Add your control notification handler code here
char buf1[1000];
char buf2[1000];
XNode node1;
XNode node2;
if( LoadFromFile("a.xml", buf1) == 0 )
{
AfxMessageBox("no file a.xml");
return;
}
if( LoadFromFile("b.xml", buf2) == 0 )
{
AfxMessageBox("no file b.xml");
return;
}
if(node1.Load(buf1) == 0 )
{
AfxMessageBox("xml load fail a.xml");
return;
}
if(node2.Load(buf2) == 0 )
{
AfxMessageBox("xml load fail b.xml");
return;
}
// test show a.xml and b.xml
AfxMessageBox( node1.GetXML() );
AfxMessageBox( node2.GetXML() );
// now, find GRAPH node of a.xml to get inserting point.
LPXNode pNode = node1.Find("GRAPH");
if( pNode )
{
// test show GRAPH node of a.xml
AfxMessageBox( pNode->GetXML() );
// now, find ID nodes of b.xml to insert
XNodes childs_of_node2 = node2.GetChilds(_T("ID") );
for( int i = 0 ; i < childs_of_node2.size(); i++)
{
// insert node branch of b.xml's ID nodes to a.xml
pNode->AppendChildBranch(childs_of_node2[i]);
}
// test show result
AfxMessageBox( node1.GetXML() );
}
}
Thank you all. No one know oneself all. My idea from you, book, all others. already we are shared brains.
|
|
|
|
|
It is very useful. Thanks, bro. One thing, how to write the new XML to the file (a.xml) after adding the second file onto the first one? I think maybe "fwrite" will work, but its first parameter needs to be const void *. How can I do this? If possible, after the inserting, the next time I open a.xml, it would be the new node1.
Thanks a lot.
|
|
|
|
|