I have a XML file and a a bunch of XSD files with schemas. How do I parse the XML file using the correct XSD file and schema in PHP?
A:
You can use the DOM or XmlReader extensions
DOMDocument::schemaValidate
— Validates a document based on a schemaXMLReader::setSchema
— Validate document against XSD
to validate documents against a schema.
Gordon
2010-07-14 08:49:03
Thanks. But i would like to parse the XML file (get the values), not validate it
jonasl
2010-07-15 07:50:12
@jonas Could you update your question and provide an example please? I'm not sure I understand what you are trying to do.
Gordon
2010-07-15 10:37:39
+1
A:
Check this tool - http://github.com/moyarada/XSD-to-PHP. It sounds exactly what you're asking. You can marshal/unmarshal XML usind generated from XSD PHP classes.
Mike Bevz
2010-08-10 18:28:43