I want to create a xml file from the data given by the users.
I can use simplexml or DOMDocument for creating xml files and even there is an option in DOMDocument to verify the xml document with a schema .
But what i need is instead of creating nodes and adding values using xml classes, can i create a xml file from the data stored somewhere else in respect with a schema?
I think in .net there is an option to write into xml from reading from dataset.. But i couldn't find such thing in PHP.
Is that possible and are there any classes for that?
If there are no predefined classes , at least any help on any ways of doing that?
Edit:
I'm editing this question because it seems that some of you is not clear about my requirement..
For example, if the schema is
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
attributeFormDefault="unqualified">
<xs:element name="formpatterns">
<xs:element name="pan" type="pantype"/>
<xs:element name="name" type="nametype"/>
<xs:element name="fatherName" type="nametype"/>
<xs:group ref="address"/>
<xs:element name="dob" type="xs:date"/>
</xs:schema>
and if user gives the data for pan, name, fathername, address, dob then i need to create the xml document automatically by matching the schema and data.
The schema may change from time to time , so i dont want to edit all the code to create/ change nodes and attributes. I need just to point the new schema , so that the code creates the xml based on that.
An XML Schema describes the structure of an XML document, just like a DTD. An XML document with correct syntax is called "Well Formed". An XML document validated against an XML Schema is both "Well Formed" and "Valid".
Have a look at https://github.com/moyarada/XSD-to-PHP it compiles PHP bindings from XSD, and then you can serialize PHP classes to XML.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With