Announcement

Collapse
No announcement yet.

xml save and update

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • xml save and update

    Hi there!
    I wish that someone helps me in the next code :
    A- Before adding a new data, I want to check if the (elev_no) or the (id) exists before , if it already exists in the xml database then message (the student or the id exists) , if not then add the new data.
    B- Before updating the existed data, if the user tries to change or modify the (elev_no) or the (id) which is already exist in the xml database then message (the student or the id exists) , if not then update the data.

  • #2
    And now here it is my code :
    strName = Input.GetText("name");
    strNo = Input.GetText("Elev_No");
    strPhone = Input.GetText("phone");
    strAdresse = Input.GetText("el_adresse");

    --XML.InsertXML("database/eleve", "<eleve>\n<name>"..strName.."</name>\n<elev_no>"..strNO.."</elev_no>\n</eleve>\n", XML.INSERT_BEFORE);

    strXML = "<eleve id='"..strNo.."'>\n<name>"..strName.."</name>\n<elev_no>"..strNO.."</elev_no>\n";
    strXML = strXML.."<phone>"..strPhone.."</phone>\n<adresse>"..strAdresse.."</adresse>\n</eleve>\n";

    -- adding a new student

    if add_or_edit == "add" then

    nCount = XML.Count("database", "eleve");

    XML.InsertXML("database/eleve:"..nCount, strXML, XML.INSERT_AFTER);

    -- modifing a student

    elseif add_or_edit == "edit" then
    local tbSelect = ListBox.GetSelected("Listcontent");
    XML.InsertXML("database/eleve:"..tbSelect[1], strXML, XML.REPLACE);
    end
    --XML.Save("AutoPlay\\Docs\\elev_data.xml");

    XML.Save(_SourceFolder.."\\AutoPlay\\Docs\\elev_da ta.xml");

    ListBox.DeleteItem("Listcontent", LB_ALLITEMS);
    fill_list()
    Button.SetEnabled("Add", true);
    Button.SetEnabled("Edit", true);
    Button.SetEnabled("save", false);

    Comment

    Working...
    X