Witam was, po raz kolejnym. mam dwa drobne problemy. plik zapisuje do XML - to gra pieknie.

Ale kiedy chce dodac nastepny rekord pod tym obecnym to juz ciezej. a teraz kod:

  1. <html>
  2. <body>
  3. <form method="POST">
  4. Action: <select name="action">
  5. <option value="Select">Select</option>
  6. <option value="Wash 7?">Add Wash</option>
  7. <option value="Mini Valet 50?">Add Mini Valet</option>
  8. <option value="Wash & Vac 20?">Add Wash & Vac</option>
  9. <option value="Full Valet 120?">Add Full Valet</option>
  10. </select>
  11. <br/>
  12. Other: <input name="other" type="text">Price:<input name="price" type="text">
  13. <input type="submit" Value="Add">
  14. </form>
  15. </body>
  16. </html>
  17.  
  18. <?php
  19.  
  20. $action=$_POST['action'];
  21. $other=$_POST['other'];
  22. $price=$_POST['price'];
  23.  
  24. $dane='<?xml version="1.0"?>
  25. <?xml-stylesheet type="text/xsl" href="xsl.xsl"?>
  26. <SERWIS>
  27. <ACTION>
  28. <ORDINARY>'.$action.'</ORDINARY>
  29.  
  30.  
  31. <OTHER>'.$other.'</OTHER><PRICE>'.$price.'</PRICE>
  32. </ACTION>
  33. </SERWIS>
  34. ';
  35. $wp=fopen('action.xml', 'w+');
  36. fwrite($wp, $dane);
  37. fclose($wp);
  38.  
  39. $newa = new DOMDocument();
  40. $newa -> load('action.xml');
  41.  
  42. //Get the <ACTION> tag
  43. $add = $newa -> getElementsByTagName('ACTION');
  44.  
  45. //Create the new <new_rec> tag
  46. $newGame = $newa -> createElement("new_rec");
  47. $newGame -> appendChild($newa -> createElement("ORDINARY", '.$action.'));
  48. $newGame -> appendChild($newa -> createElement("OTHER", '.$other.'));
  49. $newGame -> appendChild($newa -> createElement("PRICE", '.$price.'));
  50.  
  51. //Add the new <new_rec> tag under the <ACTION> tag
  52. $add -> item(0) -> appendChild($newGame);
  53.  
  54. //Save again
  55. $newa -> save('action.xml');
  56. ?>

no i blady:

Warning: DOMDocument::load(): Input is not proper UTF-8, indicate encoding ! Bytes: 0x80 0x3C 0x2F 0x4F in file:///C:/wamp/www/action.xml, line: 5 in C:\wamp\www\simple.php on line 36

Fatal error: Call to a member function appendChild() on a non-object in C:\wamp\www\simple.php on line 48

Szukalem w google probowolem roznych opcji/ zmian kodu. Nie ogarniam. 1 raz robie zapis pliku XML a jeszcze przedema odczyt i wyswietlenie do druku biggrin.gif

Ale tymczasem jakies podpowiedzi (gotowe rozwiazania hahah [taki zarcik]biggrin.gif)