473,396 Members | 1,784 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Reading XML Stream in C++

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
Nov 16 '06 #1
2 1133
"Mayur" <ma***@activelement.comwrote in message
news:uC**************@TK2MSFTNGP03.phx.gbl...
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>
...
</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..
Microsoft supplies a COM component called MSXML that can do that. If you
don't have the latest version you should be able to find it here:

http://msdn.microsoft.com/XML/XMLDownloads/

If you want to use it you "import" it into your source and the compiler will
generate header files from the component's type library.

Alternatively, you can find any of a number of hand-rolled C++ wrappers,
e.g.,

http://www.codeguru.com/cpp/data/dat...cle.php/c4575/

http://www.codeproject.com/soap/msxmlcpp.asp

though I should tell you that I know nothing of the classes in the last two
links except that they came up first in a search.

Regards,
Will
Nov 16 '06 #2
Mayur wrote:
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..
Mayur:

I had a similar requirement and got back a similar xml string. Rather than go
through the hassle of using xml to process it, I wrote a simple function:
char * get_string(char *msg, char *pfx, char *sfx)
that looked for pfx in msg. If it found it, it looked for sfx after that point
and returned an allocated string of what was between. Worked like a charm.
It returns NULL if it can't find anything.

char *gameid = get_string(msg, "<game_id>", "</game_id>");

cheers!
/steveA

--
Steve Alpert
my email fgrir.nycreg @ tr.pbz is encrypted with ROT13 (www.rot13.org) and spaces

Nov 16 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

24
by: Hendrik Schober | last post by:
Hi, I have a 'std::istream' and need to read its whole contents into a string. How can I do this? TIA; Schobi
6
by: bas | last post by:
hey, I am having a lot of trouble trying to get this program to work properly. It is supposed to read integers from a file and place them into the categories for inventory. The problem seems to...
6
by: KevinD | last post by:
assumption: I am new to C and old to COBOL I have been reading a lot (self teaching) but something is not sinking in with respect to reading a simple file - one record at a time. Using C, I am...
3
by: Nick | last post by:
I have found a class that compresses and uncompresses data but need some help with how to use part of it below is the deflate method which compresses the string that I pass in, this works OK. At...
21
by: JoKur | last post by:
Hello, First let me tell you that I'm very new to C# and learning as I go. I'm trying to write a client application to communicate with a server (that I didn't write). Each message from the...
2
by: Joe | last post by:
Anyone can suggest the best method of reading XML and adding data to ListView? Here is the xml data structure:: <xml> <site> <url>http://www.yahoo.com</url> <lastupdate></lastupdate>...
8
by: T Driver | last post by:
Anyone have any idea how I can do the following? I have a connection to an XML file on a site I do not control, getting a string representation of the xml data that I can then feed to my...
3
by: rsk | last post by:
Hi Friends, I have the following code which reads the hexadecimal data from the "data.txt" file into the arrays. But when i run this code it is reading some garbage data after reading all the...
21
by: Stephen.Schoenberger | last post by:
Hello, My C is a bit rusty (.NET programmer normally but need to do this in C) and I need to read in a text file that is setup as a table. The general form of the file is 00000000 USNIST00Z...
2
by: =?Utf-8?B?VHJlY2l1cw==?= | last post by:
Hello, Newsgroupians: In regards to reading a stream, I know we use the Read() method. One could implement reading a stream using a while-loop. while (stream.Read(buffer, 0, buffer.Length) !=...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.