0

Possible Duplicate:
A simple program to CRUD node and node values of xml file

I have an xml file from which I get data. I also got multiple <date></date> tags in which I would like to store some date values: year, month, day, hour, minutes.

I enter the XML data manually, so my question is how do I write the required date values so when I do a file_get_contents() from PHP and then get each individual tag, PHP would understand the date and place it in a variable/object, instead of me processing the string and creating a Date variable?

Community
  • 1
  • 1
AndreiBogdan
  • 10,858
  • 13
  • 58
  • 106
  • 2
    There is no way for PHP to automagically detect dates in an XML file. You will have to parse the elements holding the dates and make them into DateTime objects or whatever you want them to be. – Gordon Sep 03 '12 at 11:32
  • oh. damn. ok then. Please write your answer as a response, so i can accept it and be done with this post. And no, it doesn't seem to be a duplicate of that post :) – AndreiBogdan Sep 03 '12 at 11:33

1 Answers1

1

There is no way for PHP to automagically detect dates in an XML file. You will have to parse the elements holding the dates and make them into DateTime objects or whatever you want them to be.

See Best XML Parser for PHP for options.

Community
  • 1
  • 1
Gordon
  • 312,688
  • 75
  • 539
  • 559
  • see if you might know how to answer my other questions as well cause you're good :) http://stackoverflow.com/questions/12246401/how-to-handle-data-on-the-server-side – AndreiBogdan Sep 03 '12 at 11:46