Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void LoadXML(String ^link)
- {
- Lista<XMLObject> *LLS = new Lista<XMLObject>();
- XmlTextReader ^reader = gcnew XmlTextReader(link);
- String ^SEl = gcnew String("");
- int cont = 0;
- XMLObject *Obj = NULL;
- string valor = "";
- string campo = "";
- while(reader->Read())
- {
- switch(reader->NodeType)
- {
- case XmlNodeType::Element: // The node is an element
- if((reader->Value!="" && cont<3) || cont < 3)
- cont++;
- campo = CoisasUteis::ConverterStringTostring(reader->Name);
- if(cont == 2)
- Obj = new XMLObject(campo);
- SEl += "<"+cont+" " + reader->Name+">";
- while(reader->MoveToNextAttribute()) // Read the attributes.
- SEl += reader->Value;
- valor = "";
- break;
- case XmlNodeType::Text: //Display the text in each element.
- SEl += reader->Value;
- valor = CoisasUteis::ConverterStringTostring(reader->Value);
- if(Obj) Obj->Add(new XMLTxtVal(campo, valor));
- break;
- case XmlNodeType::EndElement: //Display the end of the element.
- SEl += "</"+cont + " " + reader->Name+">";
- SEl = "";
- cont--;
- if(cont == 1)
- LLS->AddEnd(Obj);
- valor = "";
- break;
- }
- }
- reader->Close();
- Lista<XMLTxtVal> *lp;
- int n;
- for(int i = 0; i < LLS->NElem(); i++)
- {
- lp = (*LLS)[i]->GetCampos();
- for(int j = 0; j < lp->NElem(); j++)
- {
- if((*lp)[j]->GetCampo() != "categoria")
- continue;
- for(n=0; n<LC.NElem(); n++)
- {
- if((*lp)[j]->GetValor() != LC.GetInfo(n)->GetNomeCat())
- continue;
- produto *x = new produto((*LLS)[i]);
- LC[n]->GetLP()->AddEnd(x);
- break;
- }
- if(n == LC.NElem())
- {
- categoria *c = new categoria((*LLS)[i]);
- produto *p= new produto((*LLS)[i]);
- LC.AddEnd(c);
- LC[n]->GetLP()->AddEnd(p);
- }
- break;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment