open,edit and save xml file with schema using php -
hy... i'm new in xml schema, xsl,... (i have basic understanding) on web page: http://w3schools.com/xsl/xsl_editxml.asp shown example open,edit,save xml file, asp. know how can open/edit , save xml file using php next example:
<?xml version="1.0" encoding="iso-8859-1"?> <tools> <tool id="1"> <field id="prodname"> <value>hammer hg2606</value> </field> <field id="prodno"> <value>32456240</value> </field> <field id="price"> <value>$30.00</value> </field> </tool> <tool id="2"> <field id="prodname"> <value>audi</value> </field> <field id="prodno"> <value>88885</value> </field> <field id="price"> <value>$26.00</value> </field> </tool> </tools>
and need <tool id="2">
or <tool>
enough. on replay, , don't need xsl shown on w3s, fine refresh submitted php file after submit (will ajax after).
i saw replay mr. writman on questions/377632/add-update-and-edit-an-xml-file-with-php 2 complex me...:) there simpler answer (solution). in advance!!!
to validate xml against schema file can use
domdocument::schemavalidate
— validates document based on schemadomdocument::schemavalidatesource
— validates document based on schema
example:
$document = domdocument::load('books.xml'); if ($document->schemavalidate('books.xsd')) { print 'books.xml validate against books.xsd'; }
also see these methods , examples given on manual pages:
domdocument::load
— load xml filedomdocument::getelementbyid
— searches element iddomdocument::save
— dumps internal xml tree file
you find xml manipulation dom covered extensively @ so:
Comments
Post a Comment