Skip to main content
GameDev.net gamedev.net
🔒 Locked

XML Assistance

Started by XwingVmanX Aug 1, 2012 at 10:35 PM 2 replies 2.3k views
Original Post
XwingVmanX
XwingVmanX
Can anyone point me in the right direction to learn about reading XML files using C++. I was able to find and learn how to write onto/create an xml document, but I am having trouble find information on accessing the xml document.

This is currently what I have

patientList.open("Patients.xml", ios::in);

while(!patientList.fail() && strcmp(user, name))

{
getline(patientList, str);
posOpen = str.find("");
newStr = str.substr(posOpen + 1);
posClose = newStr.find("
");
newStr = str.substr(posOpen + 1, posClose);

strcpy(name, newStr.c_str());
}

patientList.close();

Right now I have it going through the XML file, line by line trying to find a name. Now that works fine, but what I want to do next is once the name I am looking for is found I want to grab the line after it.

The XML looks like this


Ken
Happy


Bob
Sad


Mike
Scared


So I want to find the name I am looking for then grab the mood associated with that name.

Thanks for your help in advance.
XwingVmanX
XwingVmanX
Thanks I'll take a look
sungupta
sungupta
take a look at liquid xml c++ tool, it will actually output c++ code from your xml, still its better to do it yourself because thats the only way but it should certainly help you understand how to structure your code.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.