elm0s Posted November 28, 2006 Share Posted November 28, 2006 hey, I'm trying to do a search and replace type function using simpleXML. How would I go about this?I have a php file that catches values from an html form and puts them into variables like this...[code] $buildingName = $_POST["buildingName"]; //value is the Building Name $buildingStatus = $_POST["buildingStatus"]; //value either 1,2,3, or 4 $elevator = $_POST["elevator"]; //value is either true or false $electricity = $_POST["electricity"]; //value is either true or false $gas = $_POST["gas"]; //value is either true or false $hazMat = $_POST["hazmat"]; //value is either true or false $hvac = $_POST["hvac"]; //value is either true or false $sewer = $_POST["sewer"]; //value is either true or false $water = $_POST["water"]; //value is either true or false $lan = $_POST["lan"]; //value is either true or false $phone = $_POST["phone"]; //value is either true or false[/code]The whole purpose of these variables is to update the values of this xml file..I have an xml file with the following kind of structure...[code]<building status="1" name="Kell Hall"><problem elevator="false" electricity="false" gas="false" haz_mat="false" hv_ac="false" sewer="false" water="false" lan="false" phone="false"><comment>This is a comment</comment></problem></building><building status="1" name="Sparks Hall"><problem elevator="false" electricity="false" gas="false" haz_mat="false" hv_ac="false" sewer="false" water="false" lan="false" phone="false"><comment>This is a comment</comment></problem>... etc[/code]ok so with the values that I've recieved from the html form, I want to search through the xml file, find the matching building node section, and replace those values with the updated ones from the html form.Could someone help me create some kinda of function that does this type of thing?[b]$buildingName ="kell hall";[/b]<building status="1" [b]name="kell hall"[/b]>...the [b]$buildingName[/b] is the same value as the attribute "[b]name[/b]" of the building node so I thought I could just try and match them up or something?EDIT: i found something and got it to work.... Quote Link to comment https://forums.phpfreaks.com/topic/28792-simplexml-search-and-replace-type-function/ Share on other sites More sharing options...
crash369 Posted June 1, 2007 Share Posted June 1, 2007 would you mind posting the solution?i'm faced with a similar problem. Quote Link to comment https://forums.phpfreaks.com/topic/28792-simplexml-search-and-replace-type-function/#findComment-266004 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.