unvoid Posted June 4, 2009 Share Posted June 4, 2009 I want to be able to this: http://www.w3schools.com/Xsl/xsl_editxml.asp but with php so far I have been able to create the form with xslt using php but I have not figured out how to save all the newly inputted data into the xml. Here is what I have: a snippet of my xslt (which is a monster of a file): <table class="load" cellpadding="0" cellspacing="0" border="1" bordercolor="#000000" width="100%" bgcolor="#A5AC9D" style="text-align:center;"> <thead> <th style="color:#0a63a7; width:22%;">Group</th> <th style="color:#0a63a7; width:28%;">Field</th> <th style="color:#0a63a7; width:39%;">New Value</th> </thead> <xsl:for-each select="TEST_CONFIGURATION/TEST_HARNESS_HOST/NAME"> <tr> <td>TEST_HARNESS_HOST</td> <td>NAME</td> <td class="col3"><input type="text" style="width:100%;" name="TEST_CONFIGURATION/TEST_HARNESS_HOST/NAME"> <xsl:attribute name="id"> <xsl:value-of select="." /> </xsl:attribute> <xsl:attribute name="value"> <xsl:value-of select="." /> </xsl:attribute> </input> </td> </tr> </xsl:for-each> <xsl:for-each select="TEST_CONFIGURATION/TEST_HARNESS_HOST/IP_ADDRESS"> <tr><td></td> <td>IP_ADDRESS</td> <td class="col3"><input type="text" style="width:100%;" name="TEST_CONFIGURATION/TEST_HARNESS_HOST/IP_ADDRESS"> <xsl:attribute name="id"> <xsl:value-of select="." /> </xsl:attribute> <xsl:attribute name="value"> <xsl:value-of select="." /> </xsl:attribute> </input> </td> </tr> </xsl:for-each> <!-- Host 1 --> <xsl:for-each select="TEST_CONFIGURATION/HOST[@RefName='HOST_1']/NAME"> <tr><td>HOST_1</td> <td>NAME</td> <td class="col3"><input type="text" style="width:100%;" name="TEST_CONFIGURATION/HOST[@RefName='HOST_1']/NAME" > <xsl:attribute name="id"> <xsl:value-of select="." /> </xsl:attribute> <xsl:attribute name="value"> <xsl:value-of select="." /> </xsl:attribute> </input> </td> </tr> </xsl:for-each> my php so far (this loads the xml and creates the form that I want): //Reads users custom built xmldoc file to create the editable fields $rfile = $xmldoc; $freader = fopen($rfile, 'r') or die("Can't open read file"); $theData = fread($freader, filesize($rfile)); fclose($freader); // Load XML file $XML = new DOMDocument(); $XML->loadXML( $theData ); // Start xslt $xslt = new XSLTProcessor(); $XSL = new DOMDocument(); $XSL->load( $XSLpath, LIBXML_NOCDATA); $xslt->importStylesheet( $XSL ); // Print print $xslt->transformToXML( $XML ); The end goal is to allow a user to load up an xml doc using the xslt to create a form that allows them to change any of the fields in their xml document. Here is what I have been trying so far for the update function but with no success (I have ??? where I think I am on to something but I am not really sure where to go with it since I need to edit so many different random fields that the user changes): $dom = new DOMDocument(); $dom->load($eid); $xpath = new DOMXPath($dom); $values = $xpath->query('????'); foreach($values as $value) { $a = $value->nodeValue; // shortcut $currentEntry = substr($a); $userEntry = _POST[??]; $value->nodeValue = "{$userEntry}"; } $dom->save($eid); Link to comment https://forums.phpfreaks.com/topic/160944-php-creating-xml-from-a-long-xslt-form-need-some-guidance-anything/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.