Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- #include <tinyxml.h>
- #include <iostream>
- using namespace std;
- void get_person(string& find)
- {
- TiXmlDocument doc("XMLFile1.xml");
- if (!doc.LoadFile())
- return;
- TiXmlElement* element = doc.FirstChildElement("AddressBook");
- element = element->FirstChildElement("Contact");
- int answer = 0;
- TiXmlDocument ans;
- while (element != NULL) {
- if (string(element->FirstChildElement("FirstName")->GetText()) == find) {
- answer++;
- ans.LinkEndChild(new TiXmlElement(*element));
- }
- element = element->NextSiblingElement("Contact");
- }
- ans.SaveFile("XMLFile2.xml");
- cout << answer;
- }
- int main()
- {
- string have = "Ivan";
- get_person(have);
- return 0;
- }
- */
- <AddressBook>
- <Contact>
- <FirstName>Ivan</FirstName>
- <LastName>Petrov</LastName>
- <Phone>
- <phonenumber>123456</phonenumber>
- <accountindex>1</accountindex>
- <downloaded>1</downloaded>
- </Phone>
- <Groups>
- <groupid>2</groupid>
- </Groups>
- </Contact>
- <Contact>
- <FirstName>Petr</FirstName>
- <LastName>Sidorov</LastName>
- <Phone>
- <phonenumber>456789</phonenumber>
- <accountindex>1</accountindex>
- <downloaded>1</downloaded>
- </Phone>
- <Groups>
- <groupid>2</groupid>
- </Groups>
- </Contact>
- <Contact>
- <FirstName>Petr</FirstName>
- <LastName>Sidorov</LastName>
- <Phone>
- <phonenumber>456789</phonenumber>
- <accountindex>1</accountindex>
- <downloaded>1</downloaded>
- </Phone>
- <Groups>
- <groupid>2</groupid>
- </Groups>
- </Contact>
- </AddressBook>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement