|
Hi Cho, Kyung-min,
Does the parser cope with multiple branches?
I tried the following XML in your examples, but only the first branch (AddressBook) seemed to be accessible:-
sxml = _T("<addressbook description="\"book" of="" bro\"="">\
<person type="me"><name>Cho,Kyung Min<nick>bro\
<person type="friend"><name>Baik,Ji Hoon<nick>bjh\
<person type="friend"><name>Bak,Gun Joo<nick>dichter\
<information count="3">\
\
<personaldirectory description="\"book" of="" friends\"="">\
<person type="me"><name>Clark,Peter<nick>Pete\
<person type="friend"><name>Ridler,Kevin<nick>Kev\
<person type="friend"><name>Hermes,Bernard<nick>Berni\
<information count="3">\
");
Should it be possible to access to the PersonalDirectory XML section ?
Many thanks,
Peter Clark
peterashleyclark@yahoo.co.uk
|
|
|
|
|
Hi, picnic.
XMLite process one root element.
in branch copy (deep-copy) section, that code is wrong on this page. (problem with html tag processing)
but source example code is works.
and if you want to multiple root elements, I wrote already about it before.
-------------------
XNode in XMLite can parse one element.
so, xnode.Load( "<a></a><b></b><c></c>" ) , then xnode parse only .
if you want to parse all elements, then write below
( somebody ask to me how to do this )
CString s;
s = _T("<a></a><b></b><c></c>");
XNode a,b,c;
LPTSTR pa = (LPTSTR)(LPCTSTR)s;
LPTSTR pb = a.Load( pa );
LPTSTR pc = b.Load( pb );
LPTSTR pNull = c.Load( pc );
TRACE(_T("%s %s %s"), a.name , b.name, c.name );
<h6>Thank you all. No one know oneself all. My idea from you, book, all others. already we are shared brains.</h6>
-- modified at 21:04 Wednesday 25th January, 2006
|
|
|
|
|
Hi,
I am working on my thesis that about doing a server application for a company.
thay have a Messenger (it's name is Cute Messenger) and thay want me to do a server application so it can do it possible to members of Cute Messenger that chat with thier friends on MSN messenger or ICQ or Yahoo messenger.
I am a newbie and I have hort that it can be possible by Jabber, I saw your aricle and i thought you maybe can help me and give some advice or tip.
you can write to me dirctly to my mail: arash22@hotmail.com
thank you so much.
and sorry about my bad english
arash
|
|
|
|
|
I worked with jabber server as you see on my introduction page, I choose win32 jaber com client library, but at that time, jabercom doesn't support korean language.
so i make own jaber client program. XMLite is a by-product in that project.
jabber.org shows how can talk with jabber server.
sorry for my poor english too.
Thank you all. No one know oneself all. My idea from you, book, all others. already we are shared brains.
|
|
|
|
|
In fact, XMLite has almost thought about UNICODE, but we need to make a little correcting work :
1. add these code to XMLite.h
<br />
#ifdef _UNICODE<br />
typedef std::wostringstream tostringstream;<br />
#define _tmemcpy wmemcpy<br />
#else<br />
typedef std::ostringstream tostringstream;<br />
#define _tmemcpy memcpy<br />
#endif<br />
2. some changes in XMLite.cpp
(1)find all "std::ostringstream", change them to "tostringstream"
(2)in function "_SetString", find
<br />
memcpy( pss, psz, len );<br />
change "memcpy" to "_tmemcpy"
then it seems work fine, but I've not tested a lot
|
|
|
|
|
Hi, Hewllet.
Thanks for your advice.
Your share thing will be help me and others.
Thank you all. No one know oneself all. My idea from you, book, all others. already we are shared brains.
|
|
|
|
|
Hi,
You can do this much simpler.
typedef std::basic_ostringstream<tchar, std::char_traits<tchar="">, std::allocator<tchar> > tostringstream;
|
|
|
|
|
GetChildIterator may return NULL.
This may cause RemoveChild and DetachChild to run vector::erase(NULL) which is likely to produce a crash.
Feels to me like GetChildIterator should return childs.end() if the node isn't found. (Also, returning childs.end() feels a bit more "stl-like" then returning NULL).
|
|
|
|
|
|
You are nice too, duan zuoyi.
Thank you all. No one know oneself all. My idea from you, book, all others. already we are shared brains.
|
|
|
|
|
Great project, very useful.
I notice when you use GetBufferSetLength(), there is no corresponding releaseBuffer call. That is adding an extra '\0' at the end of CString and make the size of CString one bigger.
|
|
|
|
|
GetBufferSetLength() needs no ReleaseBuffer(). But you are right with the size problem. See my reply to Fernando A. Gómez' post on 15-May-06 12:54.
|
|
|
|
|
One of the reasons of XML is connecting platforms, apps through text encoded messages, to achieve this you need compliance. Implementing a fully (95%-98%) compliant XML parser is really hard. Usually an average Dev can get to 80% pretty quickly and the experienced can get to %90. The rest is all egde cases and getting them right requires extensive testing suites to ensure compat between different platforms. I know this by experience. There are quite a few xml parser implementations out there. Users are usually best served when the xml parser implementations are recognized by the W3C Recommendations. Other implementations can not go any further than academic studies as the cost of them making interop with the rest of the world sky rockets as dev's are trying to achieve %95 compat.
|
|
|
|
|
My thoughts on it:
A lot of warning C4018: '<' : signed/unsigned mismatch when compiling. Doesn't really matter but should be fixed.
Also, a couple of error C2451: conditional expression of type 'std::vector<_Ty>::iterator' is illegal
For example, in bool _tagXMLNode::RemoveChild( LPXNode node ), you do
if( it )
What's that supposed to mean? Shouldn't it be something like if( it != childs.end())?
|
|
|
|
|
I get the errors in vs.net,but successful in vs6.0;P
|
|
|
|
|
I met the same error of "if( it )" in vs .net.
According to the source code of "GetChildIterator()", change "if( it )" to
if ( it != NULL)
All will be OK in vs. net.
|
|
|
|
|
I'd like to let you know how usefull was your code for the project i'm working on...thank you so much, keep up the good work!
|
|
|
|
|
do your xml parse support other language?
for example, xml file include other language such as chinese.
thank you.
|
|
|
|
|
it support other language.
thank you for your good parse!
|
|
|
|
|
you can add simple utility functions for attributes.
in header.
// in own attribute list
LPXAttr GetAttr( LPCTSTR attrname );
LPCTSTR GetAttrValue( LPCTSTR attrname );
XAttrs GetAttrs( LPCTSTR name );
int GetAttrCount(); //added
XAttrs GetAttrs(); //added
in cpp
//========================================================
// Name : GetAttrCount
// Desc : get attributes node count
// Param :
// Return : 0 return if no attributes
//--------------------------------------------------------
// Coder Date Desc
// bro 2005-05-06
//========================================================
int _tagXMLNode::GetAttrCount()
{
return attrs.size();
}
XAttrs _tagXMLNode::GetAttrs()
{
return attrs;
}
-----------------------------------------------------------
you can also walk on attributes using upper functions
XAttrs attrs = node->GetAttrs();
for( int i = 0 ; i < attrs.size(); i ++ )
{
LPXAttr attr = attrs[i];
TRACE( "%s\n", attr->name );
}
another method
XAttrs attrs = node->GetAttrs();
for( int i = 0 ; i < node->GetAttrCount; i ++ )
{
LPXAttr attr = node->GetAttr(i);
TRACE( "%s\n", attr->name );
}
Thank you all. No one know oneself all. My idea from you, book, all others. already we are shared brains.
|
|
|
|
|
I have added to my project files XMLite.h and XMLite.cpp, then I have appended this code to XMLite.h:
#include <afxwin.h> // MFC core and standard components
#include <afxext.h> // MFC extensions
#include <afxdisp.h> // MFC Automation classes
#include <afxdtctl.h> // MFC support for Internet Explorer 4 Common Controls
#ifndef _AFX_NO_AFXCMN_SUPPORT
#include <afxcmn.h> // MFC support for Windows Common Controls
#endif // _AFX_NO_AFXCMN_SUPPORT
At the end when I have built my project, I have got:
Nafxcwd.lib(dllmodul.obj) : error LNK2005: _DllMain@12 already defined in
Could you give a suggestion to go on?
Thanks in advance,
Best Regard
Nicola
Nicola
|
|
|
|
|
I can't see include files on your code.
( you should write with < and >
btw, why did you insert those include files in xmlite header?
I think that's not good style.
you can find about this problem in 'Linker Tools Error LNK2005' on MSDN
Thank you all. No one know oneself all. My idea from you, book, all others. already we are shared brains.
|
|
|
|
|
how show all attributte: name and id from this xml:
<iq type='result'><users><user name='userone' id='1' /><user name='usertwo' id='2' /><user name='userthree' id='3' /><user name='userfour' id='4' /></users></iq> ??
|
|
|
|
|
here is code. you can get all nodes and attributes with simple recursively function
void show_attrs( LPXNode node )
{
for( int i = 0 ; i < node->attrs.size(); i ++)
{
LPXAttr attr = node->attrs[i];
TRACE("%s %s\n", attr->name, attr->value );
}
}
void walk_node( LPXNode node )
{
TRACE("%s %s\n", node->name, node->value );
// show attributes itself
show_attrs( node );
// walk childs recursively
for( int i = 0; i < node->childs.size(); i ++)
{
LPXNode child = node->childs[i];
walk_node( child );
}
}
void CTestXMLiteDlg::OnButton13()
{
// TODO: Add your control notification handler code here
CString sXML = "<iq type="result"><users><user name="userone" id="1"><user name="usertwo" id="2"><user name="userthree" id="3"><user name="userfour" id="4">";
XNode node;
if( node.Load( sXML ) )
{
walk_node( &node );
}
}
then you can get trace strings
iq
type result
users
user
name userone
id 1
user
name usertwo
id 2
user
name userthree
id 3
user
name userfour
id 4
Thanks for regard.
sorry for late answering.
Thank you all. No one know oneself all. My idea from you, book, all others. already we are shared brains.
|
|
|
|
|
I got a some question mail for getting full xml with PI.
XNode is for XML elemnet node. element node hasn't PI ( <?xml?> ).
newly supported XDoc is for XML Document. it has PI node and real root xml element node. ( using GetRoot() )
CString sxml;
sxml = _T("<?xml version='1.0'?><a>value</a>");
XNode xml;
//XDoc xml;
xml.Load( sxml );
AfxMessageBox( xml.GetXML() );
=> XNode output : <a>value</a>
=> XDoc output : <?xml version='1.0'?><a>value</a>
if you want to get full PI xml source. then use XDoc.
<h6>Thank you all. No one know oneself all. My idea from you, book, all others. already we are shared brains.</h6>
|
|
|
|