Hi,
Is there any way in PHP to read an XML file in and bind the contents to an instance of a given class?
I've done something similar in .NET using serialization which reads a XML config file and then automatically populates the properties of a Config object.
E.g.
// Create an instance of the XmlSerializer specifying type and namespace.
XmlSerializer serializer = new XmlSerializer(typeof(Config));
// A FileStream is needed to read the XML document.
FileStream fs = new FileStream(filename, FileMode.Open);
XmlReader reader = new XmlTextReader(fs);
// Use the Deserialize method to restore the object's state.
Config appConfig;
appConfig = (Config) serializer.Deserialize(reader);
Hence you have an object called appConfig of type Config.
TIA
Dave