hi everyone
i need to read a xml file that look like this
<PERIODIC_TABLE>
<ELEMENT number="1" name="Hydrogen" symbol="H" period="1" group="1" series="Nonmetal" mass="1,00794" radius="0,79"></ELEMENT>
<ELEMENT number="2" name="Helium" symbol="He" period="1" group="18" series="Noble gas" mass="4,002602" radius="0,49"></ELEMENT>
<ELEMENT number="3" name="Lithium" symbol="Li" period="2" group="1" series="Alkali metal" mass="6,941" radius="2,05"></ELEMENT>
<ELEMENT number="4" name="Beryllium" symbol="Be" period="2" group="2" series="Alkaline earth metal" mass="9,012182" radius="1,4"></ELEMENT>
<ELEMENT number="5" name="Boron" symbol="B" period="2" group="13" series="Metalloid" mass="10,811" radius="1,17"></ELEMENT>
<ELEMENT number="6" name="Carbon" symbol="C" period="2" group="14" series="Nonmetal" mass="12,0107" radius="0,91"></ELEMENT>
<ELEMENT number="7" name="Nitrogen" symbol="N" period="2" group="15" series="Nonmetal" mass="14,0067" radius="0,75"></ELEMENT>
<ELEMENT number="8" name="Oxygen" symbol="O" period="2" group="16" series="Nonmetal" mass="15,9994" radius="0,65"></ELEMENT>
<ELEMENT number="9" name="Fluorine" symbol="F" period="2" group="17" series="Halogen" mass="18,9984032" radius="0,57"></ELEMENT>
<ELEMENT number="10" name="Neon" symbol="Ne" period="2" group="18" series="Noble gas" mass="20,1797" radius="0,51"></ELEMENT>
<ELEMENT number="11" name="Sodium" symbol="Na" period="3" group="1" series="Alkali metal" mass="22,98976928" radius="2,23"></ELEMENT>
<ELEMENT number="12" name="Magnesium" symbol="Mg" period="3" group="2" series="Alkaline earth metal" mass="24,305" radius="1,72"></ELEMENT>
<ELEMENT number="13" name="Aluminium" symbol="Al" period="3" group="13" series="Poor metal" mass="26,9815386" radius="1,82"></ELEMENT>
<ELEMENT number="14" name="Silicon" symbol="Si" period="3" group="14" series="Metalloid" mass="28,0855" radius="1,46"></ELEMENT>
<ELEMENT number="15" name="Phosphorus" symbol="P" period="3" group="15" series="Nonmetal" mass="30,973762" radius="1,23"></ELEMENT>
<ELEMENT number="16" name="Sulfur" symbol="S" period="3" group="16" series="Nonmetal" mass="32,065" radius="1,09"></ELEMENT>
</PERIODIC_TABLE>
the idea is to get the values of each atribute, so far i have
using namespace std;
.cxx
int main(int argc, char* argv[])
{
char Linea[500];
char *p;
ifstream entrada;
entrada.open("C:\\Users\\pedro\\Contacts\\Documents\\4 EDD\\Taller2 - TADs\\data.xml");
if(entrada)
{
while(!entrada.eof())
{
entrada.getline(Linea,sizeof(Linea));
p=strtok(Linea,"<>=/_ ");
while(p!=NULL)
{
cout<<p<<endl;
p=strtok(NULL,"<>=/_ ");
}
}
}
system("PAUSE");
return (0);
}
.h
#ifndef __TALLER2TAD__H__
#define __TALLER2TAD__H__
#include <iostream>
class elemento
{
public:
int number;
char name;
char symbil;
int period;
int grup;
char series;
double mass;
double radius;
};
#include "taller2TAD.hxx"
#endif
any idea of how to finish this, i been going it for hours
thnxs