0

XML File:

    <?xml version="1.0"?>

-<Information xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">


-<person>

<IDNumber>O-0027</IDNumber>

<Date>October 27, 2017</Date>

<Time>14:22:23</Time>

<Status>Time In</Status>

</person>

</Information>

Code:

xdoc1.Load("attendance.xml");
            XmlNode person = xdoc1.CreateElement("person");
            XmlNode name = xdoc1.CreateElement("IDNumber");
            name.InnerText = Name.Text;
            person.AppendChild(name);

            XmlNode datedate = xdoc1.CreateElement("Date");
            datedate.InnerText = datetime.ToString("MMMM dd, yyyy");
            person.AppendChild(datedate);

            XmlNode age = xdoc1.CreateElement("Time");
            Time.InnerText = datetime.ToString("HH:mm:ss");
            person.AppendChild(age);

Status " Time in " in xml. I manually putted it in.

Heres my question guys, Help me. if an IDNumber already exist, How can i append a new one that makes the status " Time out ", And if doesnt exist. How can i make it "Time In"?

Chddz
  • 15
  • 4
  • I would suggest to make objects from xml via https://stackoverflow.com/questions/10518372/how-to-deserialize-xml-to-object – Cars Ten Oct 27 '17 at 07:36
  • Are you trying to read or write xml. You question implies reading, but your sample code is creating an xml. – jdweng Oct 27 '17 at 08:06

0 Answers0