I'm attempting to extract the date saved in the <PersonDetails> tag for some XML I am working with, example:
<Record> <PersonDetails RecordDate="2017-03-31T00:00:00"> <FirstName>Joe</FirstName> <Surname>Blogs</Surname> <Status>Active</Status> </PersonDetails> </Record> Currently I have been trying the following:
if (isset($XML->Record->xpath("//PersonDetails[@RecordDate]")[0])) { $theDate = $XML->Record->xpath("//PersonDetails[@RecordDate]")[0])->textContent; } else { $theDate = "no date"; } My intention is to have $theDate = 2017-03-31T00:00:00