geniuscapri Posted March 25, 2008 Share Posted March 25, 2008 Hello Developers, i want to edit XML values with php. any one can help me??? Quote Link to comment https://forums.phpfreaks.com/topic/97764-xml/ Share on other sites More sharing options...
geniuscapri Posted March 25, 2008 Author Share Posted March 25, 2008 no any one know??? Quote Link to comment https://forums.phpfreaks.com/topic/97764-xml/#findComment-500220 Share on other sites More sharing options...
Cep Posted March 25, 2008 Share Posted March 25, 2008 Read the php manual regarding XML. http://www.php.net/manual/en/ref.xml.php No one will help you if you do not help provide more then a sentence worth of information. We are not mind readers. Quote Link to comment https://forums.phpfreaks.com/topic/97764-xml/#findComment-500227 Share on other sites More sharing options...
geniuscapri Posted March 26, 2008 Author Share Posted March 26, 2008 again here. i have 3 input fields UserName: CountryName: Age: i want to insert this out put data in XML. it should be multiple data. and after adding i also want to edit them or delete. any one can help me about it??? This is a experiment :-\ Quote Link to comment https://forums.phpfreaks.com/topic/97764-xml/#findComment-501021 Share on other sites More sharing options...
lordfrikk Posted March 26, 2008 Share Posted March 26, 2008 Here's example, but it's really badly coded :-P <?php $username = 'hideous'; $countryname = 'Antarctica'; $age = 99; $filename = 'userdata.xml'; $tmp = <<<DELIMITER <?xml version="1.0" encoding="UTF-8"?> <user> <name>$username</name> <country>$countryname</country> <age>$age</age> </user> DELIMITER; $xml = simplexml_load_string($tmp); file_put_contents($filename, $xml->asXml()); ?> Quote Link to comment https://forums.phpfreaks.com/topic/97764-xml/#findComment-501037 Share on other sites More sharing options...
geniuscapri Posted March 26, 2008 Author Share Posted March 26, 2008 no any reply :'( Quote Link to comment https://forums.phpfreaks.com/topic/97764-xml/#findComment-501094 Share on other sites More sharing options...
lordfrikk Posted March 26, 2008 Share Posted March 26, 2008 Well I did reply, but you should also use Google and search for some basic XML handling in PHP. Quote Link to comment https://forums.phpfreaks.com/topic/97764-xml/#findComment-501105 Share on other sites More sharing options...
geniuscapri Posted March 26, 2008 Author Share Posted March 26, 2008 This is My XML Code! <users_acounts> <user_info> <username>asdfasd</username> <password>fasd</password> <firstname>fasdf</firstname> <lastname></lastname> <email></email> <mail_stop></mail_stop> <phone></phone> <permission> <readonly>no</readonly> <img_manager>no</img_manager> <doc_share>no</doc_share> <CPX>no</CPX> </permission> </user_info> <user_info> <username>fhjfgjhfg</username> <password>jhfgjhfg</password> <firstname>jhfgjhfghj</firstname> <lastname></lastname> <email></email> <mail_stop></mail_stop> <phone></phone> <permission> <readonly>no</readonly> <img_manager>no</img_manager> <doc_share>no</doc_share> <CPX>no</CPX> </permission> </user_info> </users_acounts> and This is my PHP Code <?php $file = 'testFile.xml'; if (file_exists($file)) { // load file $xml = simplexml_load_file($file) or die ("Unable to load XML file!"); $userinfo_tag=$xml->user_info; foreach($userinfo_tag as $userinfo_tag2) { $xml = simplexml_load_file($file) or die ("Unable to load XML file!"); $username_tag=$userinfo_tag2->username; foreach($username_tag as $un_value) { echo $un_value; } ?> every thing is working. now want to edit any some values who's between <user_info> </ user_info> tags. now start my problem i am going to send user_info as ref to another page for edit my xml data. i am doing this with. <a href="user_edit.php?userinfo=<?php echo $userinfo_tag2;?>">Edit</a> But $userinfo_tag2 is not going to my next page. now Rovas can you help me??? Quote Link to comment https://forums.phpfreaks.com/topic/97764-xml/#findComment-501215 Share on other sites More sharing options...
geniuscapri Posted March 26, 2008 Author Share Posted March 26, 2008 again no any reply Quote Link to comment https://forums.phpfreaks.com/topic/97764-xml/#findComment-501263 Share on other sites More sharing options...
lordfrikk Posted March 26, 2008 Share Posted March 26, 2008 <a href="user_edit.php?userinfo=<?php echo $userinfo_tag2;?>">Edit</a> If you append it this way to the URL then you can access the value in user_edit.php from variable $_GET['userinfo']. Quote Link to comment https://forums.phpfreaks.com/topic/97764-xml/#findComment-501271 Share on other sites More sharing options...
Demonic Posted March 26, 2008 Share Posted March 26, 2008 Read this http://hudzilla.org/phpwiki/index.php?title=XML_and_XSLT Quote Link to comment https://forums.phpfreaks.com/topic/97764-xml/#findComment-501385 Share on other sites More sharing options...
geniuscapri Posted March 27, 2008 Author Share Posted March 27, 2008 only one reply Quote Link to comment https://forums.phpfreaks.com/topic/97764-xml/#findComment-501924 Share on other sites More sharing options...
Cep Posted March 27, 2008 Share Posted March 27, 2008 People DO NOT have to help you, they are here giving THIER free time to HELP people, STOP posting that you only receive one reply, you have received several and doing so only encourages the rest of us to ignore you. Quote Link to comment https://forums.phpfreaks.com/topic/97764-xml/#findComment-501981 Share on other sites More sharing options...
geniuscapri Posted March 27, 2008 Author Share Posted March 27, 2008 why ignore me???????????????? i am not spaming here or any thing wrong. i am just asking for help. but no any one helping me. then why icont do it.??? its only reaction. :-X Quote Link to comment https://forums.phpfreaks.com/topic/97764-xml/#findComment-501983 Share on other sites More sharing options...
ansarka Posted March 27, 2008 Share Posted March 27, 2008 Please go through below links May be it will helps you http://webpages.dcu.ie/~tuited/php_primer/tut_xml_edit.htm http://www.activewidgets.com/javascript.forum.6613.0/trying-to-use-xml-php.html http://www.ister.org/code/xml22/ Quote Link to comment https://forums.phpfreaks.com/topic/97764-xml/#findComment-501988 Share on other sites More sharing options...
geniuscapri Posted March 27, 2008 Author Share Posted March 27, 2008 Thanks ansarka Quote Link to comment https://forums.phpfreaks.com/topic/97764-xml/#findComment-502028 Share on other sites More sharing options...
geniuscapri Posted March 28, 2008 Author Share Posted March 28, 2008 Thanks ansarka, Quote Link to comment https://forums.phpfreaks.com/topic/97764-xml/#findComment-502928 Share on other sites More sharing options...
ansarka Posted March 28, 2008 Share Posted March 28, 2008 Is that working :) :) Always here to help according to my and GOOGLES ;) ;) Knowledge Quote Link to comment https://forums.phpfreaks.com/topic/97764-xml/#findComment-502929 Share on other sites More sharing options...
aschk Posted March 28, 2008 Share Posted March 28, 2008 SimpleXML is great for reading xml documents but if you're planning on editing XML docs then you should probably use DomDocument(). I believe it's still the defacto in PHP5+, although i'm hoping it'll change soon. In fact having just checked as of 5.1.3 PHP now allows the creation of child nodes using simpleXML. WHOOP! Quote Link to comment https://forums.phpfreaks.com/topic/97764-xml/#findComment-503019 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.