need help reading xml file

this is my code so far

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#include <iostream>
#include <cstdlib>
#include <string>
#include <fstream>
using namespace std;

int main()
{
    string line = " ";

    ifstream fin("address.xml");

    if(fin.fail())
    {
        cout << "Opening file failed \n";
        exit(1);
    }

    while(getline(fin, line))
    {
        cout << line << endl;
    }

    return 0;
}


my output is



<address_book>
<contact>
        <name>George Clooney</name>
        <street>1042 El Camino Real</street>
        <city>Beverly Hills</city>
        <state>CA</state>
        <zip>90214</zip>
</contact>
<contact>
        <name>Cathy Pearl</name>
        <street>405 A St.</street>
        <city>Palmdale</city>
        <state>CA</state>
        <zip>93352</zip>
</contact>
<contact>
        <name>Paris Hilton</name>
        <street>200 S. Elm St.</street>
        <city>Beverly Hills</city>
        <state>CA</state>
        <zip>90212</zip>
</contact>
<contact>
        <name>Wendy Jones</name>
        <street>982 Boundary Ave.</street>
        <city>Palmdale</city>
        <state>CA</state>
        <zip>93354</zip>
</contact>
</address_book>

Process returned 0 (0x0)   execution time : 0.046 s
Press any key to continue.


it's printing out exactly what is in the xml file
how do i get rid of the <word>'s in the output?
Last edited on
lol wut.



What's your goal here?
1) Scan each string for '<' symbol
2) if it is find first closing symbol '>'
3) delete them and everything between
4) repeat
5) print what left
Topic archived. No new replies allowed.