![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Unverified User
Join Date: Dec 2006
Posts: 6
Rep Power: 0
![]() |
Hi all,
I am working with c++ and new to XML. I have a work with TinyXML. I have understood classes and functions of tinyxml. I want to parse my XML file which is like this: <?xml version="1.0" encoding="utf-8"?> <users source="URL" challenge="EncodedString" session="String"> <user name="ABC" password="abc" ></user> <user name="XYZ" password="xyz" ></user> <source level=""> URL </source> </users> I want to parse this xml file using tinyxml so that related data can be transferred to database. Kindly help regards |
|
|
|
|
|
#2 |
|
Professional Programmer
Join Date: May 2006
Location: Maryland, USA
Posts: 306
Rep Power: 3
![]() |
What exactly is your problem? TinyXML is pretty easy to use, is the tutorial not enough?
|
|
|
|
|
|
#3 |
|
Programming Guru
![]() Join Date: Oct 2004
Location: namespace std
Posts: 1,246
Rep Power: 5
![]() |
i have to parse xml files for a school project i'm doing, actually not very difficult w/o libraries due to xml's nice file layout. although, i assume there's probably some way to write shitty xml...
__________________
i put on my robe and wizard hat... Have you ever heard of Plato, Aristotle, Socrates?...Morons. |
|
|
|
|
|
#4 |
|
Unverified User
Join Date: Dec 2006
Posts: 6
Rep Power: 0
![]() |
Thanx for ur replies,
I learned some documentation from net and from this link http://www.gamasutra.com/features/20...uerig_01.shtml I found, how to parse XML file using tinyxml. But just to confirm that if I follow that example and write this: class Login { public: void Parse(TiXmlHandle handle); protected: string m_name; string m_password; }; void Login: arse(TiXmlHandle handle){ TiXmlElement* section; section = handle.FirstChildElement( "user" ).Element(); section->QueryFloatAttribute( "name" , &m_name); section->QueryFloatAttribute( "password" , &m_password); } Then it will store the name and password string in m_name and m_password respectively?? Thanx for ur co-operation! regards |
|
|
|
|
|
#5 |
|
Game engine designer
Join Date: May 2005
Location: Sweden
Posts: 297
Rep Power: 4
![]() |
Due to the name of the function (QueryFloatAttribute) it feels like it queries a float attribute. There might be a function for quering strings though. Otherwise you can check out the Attribute(const char*) function. It returns a const char* for you.
A tip is to use the debugger to see if variables have gotten the correct values. Another good way is to use std::cout or printf.
__________________
http://www.klarre.se |
|
|
|
|
|
#6 |
|
Unverified User
Join Date: Dec 2006
Posts: 6
Rep Power: 0
![]() |
yes!!
Actually I directly copied the snippet so forgot to change that. There is another function QueryValueAttribute..I think it would be useful in this case. Thanks a lot for ur concern! regards |
|
|
|
|
|
#7 | |
|
Unverified User
Join Date: Dec 2006
Posts: 6
Rep Power: 0
![]() |
Quote:
|
|
|
|
|
|
|
#8 |
|
Professional Programmer
Join Date: May 2006
Location: Maryland, USA
Posts: 306
Rep Power: 3
![]() |
It depends on how you compile TinyXML, if you don't want TinyXML to use std::string then just don't define TIXML_USE_STL anywhere its that simple. If you read the documentation I linked to you would see that. All methods that say they take a std::string will take a const char* if you don't define TIXML_USE_STL.
|
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| parsing xml file using tinyxml!! | honeybee | XML | 2 | Dec 28th, 2006 11:39 PM |
| converting string to float | beginnerCCC | C | 22 | Oct 2nd, 2006 11:59 PM |
| OnlineTextEditor.Com! | Sane | Show Off Your Open Source Projects | 43 | Jun 16th, 2006 8:55 AM |
| After execution - Error cannot locate /Skin File? | wchar | Visual Basic | 1 | Mar 5th, 2005 9:04 PM |
| airport Log program using 3D linked List : problem reading from file | gemini_shooter | C++ | 0 | Mar 2nd, 2005 4:12 PM |