Discussion:
Reading XML stream using unmanaged c++
(too old to reply)
Mayur
2006-11-16 12:01:09 UTC
Permalink
Hello All,

My code below sending request to web server and getting response as XML
string.
char* response;
wf.getResponse(response,500);

where outout of above function returns xml string which is stored in
response variable.

response ="<login>
<session_id>50e39f252f247cc8e4ebb40416f16c38</session_id>
<logged_in>TRUE</logged_in>
<voice_enabled>TRUE</voice_enabled>
<ads_disabled>TRUE</ads_disabled>
<user_id>97558</user_id>
-
- <buddy_list>
<user_id>97002</user_id>
<username>unicorn11</username>
<logged_in>FALSE</logged_in>
<game_id>0</game_id>
<user_id>97562</user_id>
<username>yashwant</username>
<logged_in>FALSE</logged_in>
<game_id>0</game_id>
</buddy_list>
<auto_join_channel />
<button_config />
</login>";

I need to parse this string so that i can check output where user is logged
in whats game ID and all these parameter i required to manuoulate
my task.

where i implemeneted this in c# using XmlTextReader which is so simple but i
need it in unmanaged c++ application..


so please help me regarding this....
wating for reply.
Mayur
Vladimir Scherbina
2006-11-16 12:59:04 UTC
Permalink
This questions is wrong for this NG.

If you need to parse XML you can use 3rd party libraries. For example,
http://www.codeproject.com/soap/pugxml.asp
--
Vladimir (Windows SDK MVP)
Post by Mayur
Hello All,
My code below sending request to web server and getting response as XML
string.
char* response;
wf.getResponse(response,500);
where outout of above function returns xml string which is stored in
response variable.
response ="<login>
<session_id>50e39f252f247cc8e4ebb40416f16c38</session_id>
<logged_in>TRUE</logged_in>
<voice_enabled>TRUE</voice_enabled>
<ads_disabled>TRUE</ads_disabled>
<user_id>97558</user_id>
-
- <buddy_list>
<user_id>97002</user_id>
<username>unicorn11</username>
<logged_in>FALSE</logged_in>
<game_id>0</game_id>
<user_id>97562</user_id>
<username>yashwant</username>
<logged_in>FALSE</logged_in>
<game_id>0</game_id>
</buddy_list>
<auto_join_channel />
<button_config />
</login>";
I need to parse this string so that i can check output where user is logged
in whats game ID and all these parameter i required to manuoulate
my task.
where i implemeneted this in c# using XmlTextReader which is so simple but i
need it in unmanaged c++ application..
so please help me regarding this....
wating for reply.
Mayur
Max
2007-01-25 12:49:57 UTC
Permalink
MS XML may fit your needs.

Have a look at IXMLDOMDocument interface, method load and around in
documentation (i.e. Platform SDK documentation, or MSDN either online or
from CD).

Your code will look as follows.
//smart pointers, _variant_t, _bstr_t and other usefull stuff:
#include <comdef.h>
#include <comutil.h>
//This is a compiler com support directive that allows MSXML usage:
#import "msxml.dll"
//To the best of my understanding it is better to place the above include
and import directives in stdafx.h
VOID SomeFunc(VOID)
{
//Create XMLDOMDocument smart pointer:
MSXML::IXMLDOMDocumentPtr xmlDocumentPtr(TEXT("MSXML.DOMDocument"));
//URL of the XML file to download goes here.
_variant_t variant =
_variant_t(TEXT(http://yourdomain.com/yourfile.xml));
VARIANT_BOOL isSuccessful = VARIANT_FALSE;
HRESULT hr = xmlDocumentPtr->raw_load(variant, &isSuccessful);
if (SUCCEEDED(hr) && isSuccessful)
{
//Here you have a pointer to xml document object and can read
different settings from it.
}

}
Post by Mayur
Hello All,
My code below sending request to web server and getting response as XML
string.
char* response;
wf.getResponse(response,500);
where outout of above function returns xml string which is stored in
response variable.
response ="<login>
<session_id>50e39f252f247cc8e4ebb40416f16c38</session_id>
<logged_in>TRUE</logged_in>
<voice_enabled>TRUE</voice_enabled>
<ads_disabled>TRUE</ads_disabled>
<user_id>97558</user_id>
-
- <buddy_list>
<user_id>97002</user_id>
<username>unicorn11</username>
<logged_in>FALSE</logged_in>
<game_id>0</game_id>
<user_id>97562</user_id>
<username>yashwant</username>
<logged_in>FALSE</logged_in>
<game_id>0</game_id>
</buddy_list>
<auto_join_channel />
<button_config />
</login>";
I need to parse this string so that i can check output where user is logged
in whats game ID and all these parameter i required to manuoulate
my task.
where i implemeneted this in c# using XmlTextReader which is so simple but i
need it in unmanaged c++ application..
so please help me regarding this....
wating for reply.
Mayur
Continue reading on narkive:
Search results for 'Reading XML stream using unmanaged c++' (Questions and Answers)
5
replies
can i get question answer of asp.net ?
started 2006-10-11 00:02:47 UTC
software
Loading...