ReplaceData() with "0" problem
Brought to you by:
bs_php,
nigelswinson
From: J. C. <jan...@im...> - 2002-01-16 12:32:41
|
Hi !!! I think this problem is already known - but I could not find anything in the latest messages: When I try put the value "0" into a node it just gives me: <selectvalue/>0 instead of: <selectvalue>0</selectvalue> ------------ The test.php file: ------------------------------ <html> <head> <title>Untitled Document</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> </head> <? require_once("xpath.class.php"); $xmlfile="file.xml"; $xpath = new XPATH($xmlfile); if (isset($HTTP_POST_VARS["SUBMIT"])){ $xpath->replaceData("/DogTag[1]/selectvalue[1]",$HTTP_POST_VARS["select"]); $xpath->exportToFile($xmlfile,'','<?xml version="1.0" encoding="iso-8859-1"'.'?'.'>'); } ?> <body bgcolor="#FFFFFF"> <form method="post" action=""> <select name="select"> <option value="0" <? if ($xpath->getData("/DogTag[1]/selectvalue[1]")==0){ echo "selected";}?>>0</option> <option value="1" <? if ($xpath->getData("/DogTag[1]/selectvalue[1]")==1){ echo "selected";}?>>1</option> </select> <input type="submit" name="SUBMIT" value="Submit"> </form> </body> </html> ------------ The file.xml file: ------------------------------ <?xml version="1.0" encoding="iso-8859-1"?> <DogTag> <selectvalue>1</selectvalue> </DogTag> ---------------------------------------------------------------- By the way: 565 $xmlString = $this->exportAsXml($absoluteXPath); //Nothing modified here 566 $newline="\n"; //New 567 if (!fwrite($hFile, $xmlHeader.$newline.$xmlString)) { //New makes the head of the written xml look nicer (new Line after <? ... ?> part). Ok, till next time ... Jan |