I'm reading an .xml file with a nested for each loop. Here is a sample of the xml file
- <GroupHeader1 Type="Header">
<LoginLogoutNotice FieldName="{@Login/Logout Notice}">Jill Doe 1368</LoginLogoutNotice>
</GroupHeader1>
- <Details Type="Details">
<date FieldName="{@date}">2008-03-05</date>
<Time FieldName="{@Time}">07:55:37</Time>
<event_type FieldName="{@event_type}">Login</event_type>
<duration_login FieldName="{@duration_login}">00:00:00</duration_login>
</Details>
- <Details Type="Details">
<date FieldName="{@date}">2008-03-05</date>
<Time FieldName="{@Time}">12:00:25</Time>
<event_type FieldName="{@event_type}">Logout</event_type>
<duration_login FieldName="{@duration_login}">04:04:48</duration_login>
</Details>
- <Details Type="Details">
<date FieldName="{@date}">2008-03-05</date>
<Time FieldName="{@Time}">12:40:07</Time>
<event_type FieldName="{@event_type}">Login</event_type>
<duration_login FieldName="{@duration_login}">00:00:00</duration_login>
</Details>
- <Details Type="Details">
<date FieldName="{@date}">2008-03-05</date>
<Time FieldName="{@Time}">16:30:04</Time>
<event_type FieldName="{@event_type}">Logout</event_type>
<duration_login FieldName="{@duration_login}">03:49:57</duration_login>
</Details>
<total_login FieldName="{@total_login}">07:54:45</total_login>
Here is what the .xml file is displaying.
<groupheader1> (1 incident)
User = Jill Doe
<Details>
(This section should be 4 incidents login in the morning out for lunch login after lunch and out at end of day... Note, some users may not log out for lunch)
date = date
time = time
event = login or logut
duration = how long
<total login>
total duration = total of all time logged in
Ok, I hope that isn't confusing. Now here is my loops
$objDOM = new DOMDocument();
$objDOM->load("newphone.xml"); //make sure path is correct
$note = $objDOM->getElementsByTagName("GroupHeader1");
// for each note tag, parse the document and get values for
foreach( $note as $value )
{
$LoginLogoutNotice = $value->getElementsByTagName("LoginLogoutNotice");
$LoginLogoutNotices = $LoginLogoutNotice->item(0)->nodeValue;
$notes = $objDOM->getElementsByTagName("Details");
foreach ($notes as $value)
{
$date = $value->getElementsByTagName("date");
$dates = $date->item(0)->nodeValue;
$Time = $value->getElementsByTagName("Time");
$Times = $Time->item(0)->nodeValue;
$event_type = $value->getElementsByTagName("event_type");
$event_types = $event_type ->item(0)->nodeValue;
$duration_login = $value->getElementsByTagName("duration_login");
$duration_logins = $duration_login ->item(0)->nodeValue;
}
echo "$LoginLogoutNotices :: $dates :: $event_types :: $Times :: $duration_logins<BR> <br>";
}
I've tried several different variations, but here is what I want it to look like
Jill Doe :3/25/2008 :Login 7:30 : Logout 12:00 : Login 1:00 : Logut 4:30 : total 8:00
John Doe : 3/25/2008 : Login 8:00 : logout 4:30 : total 8:30
and so on, and so on (about 100 staff)
Ultimately I want to enter this in a database.
Thanks in advance.
- <GroupHeader1 Type="Header">
<LoginLogoutNotice FieldName="{@Login/Logout Notice}">Jill Doe 1368</LoginLogoutNotice>
</GroupHeader1>
- <Details Type="Details">
<date FieldName="{@date}">2008-03-05</date>
<Time FieldName="{@Time}">07:55:37</Time>
<event_type FieldName="{@event_type}">Login</event_type>
<duration_login FieldName="{@duration_login}">00:00:00</duration_login>
</Details>
- <Details Type="Details">
<date FieldName="{@date}">2008-03-05</date>
<Time FieldName="{@Time}">12:00:25</Time>
<event_type FieldName="{@event_type}">Logout</event_type>
<duration_login FieldName="{@duration_login}">04:04:48</duration_login>
</Details>
- <Details Type="Details">
<date FieldName="{@date}">2008-03-05</date>
<Time FieldName="{@Time}">12:40:07</Time>
<event_type FieldName="{@event_type}">Login</event_type>
<duration_login FieldName="{@duration_login}">00:00:00</duration_login>
</Details>
- <Details Type="Details">
<date FieldName="{@date}">2008-03-05</date>
<Time FieldName="{@Time}">16:30:04</Time>
<event_type FieldName="{@event_type}">Logout</event_type>
<duration_login FieldName="{@duration_login}">03:49:57</duration_login>
</Details>
<total_login FieldName="{@total_login}">07:54:45</total_login>
Here is what the .xml file is displaying.
<groupheader1> (1 incident)
User = Jill Doe
<Details>
(This section should be 4 incidents login in the morning out for lunch login after lunch and out at end of day... Note, some users may not log out for lunch)
date = date
time = time
event = login or logut
duration = how long
<total login>
total duration = total of all time logged in
Ok, I hope that isn't confusing. Now here is my loops
$objDOM = new DOMDocument();
$objDOM->load("newphone.xml"); //make sure path is correct
$note = $objDOM->getElementsByTagName("GroupHeader1");
// for each note tag, parse the document and get values for
foreach( $note as $value )
{
$LoginLogoutNotice = $value->getElementsByTagName("LoginLogoutNotice");
$LoginLogoutNotices = $LoginLogoutNotice->item(0)->nodeValue;
$notes = $objDOM->getElementsByTagName("Details");
foreach ($notes as $value)
{
$date = $value->getElementsByTagName("date");
$dates = $date->item(0)->nodeValue;
$Time = $value->getElementsByTagName("Time");
$Times = $Time->item(0)->nodeValue;
$event_type = $value->getElementsByTagName("event_type");
$event_types = $event_type ->item(0)->nodeValue;
$duration_login = $value->getElementsByTagName("duration_login");
$duration_logins = $duration_login ->item(0)->nodeValue;
}
echo "$LoginLogoutNotices :: $dates :: $event_types :: $Times :: $duration_logins<BR> <br>";
}
I've tried several different variations, but here is what I want it to look like
Jill Doe :3/25/2008 :Login 7:30 : Logout 12:00 : Login 1:00 : Logut 4:30 : total 8:00
John Doe : 3/25/2008 : Login 8:00 : logout 4:30 : total 8:30
and so on, and so on (about 100 staff)
Ultimately I want to enter this in a database.
Thanks in advance.