Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

XML

Status
Not open for further replies.

MagicalDean

Technical User
Feb 16, 2005
61
0
0
GB
This my sound like an odd question, but could I use PHP to edit parts of an XML file? What i want to do is to use XML to store 3 values, the options for a quiz. I then want some way of editing the invidual options by basically adding one to the value in the correct tag

<poll>
<option1>10</option1>
<option2>10</option1>
<option3>10</option1>
</poll>

Although that isn't correct XML, its what the thing would look like roughly. I have a system that currently does the same, but instead of one XML thingie, I have 3 txt files, each of which is edited when their option is selected in the poll

I hope that all makes sense, and any help is greatly apprechiated :)
 
Of course you can PHP to do that. However, your XML is flawed, the closing tags do not match the opening tags.

Have a look at the DOM_XML functions:

They can be easily used to load and edit an XML file. There are also valuable examples in the manual. Furthermore, if you have questions, just let us know.
 
Ok, cheers for that. I'll have a look once I get my computer up and running. If anyone else has any tips/advice/etc then please feel free to add it :)
 
Beside use DOM XML, you can use SimpleXML, here is the reference:
Make sure either domxml or simplexml exists in your php configuration.
If you are not sure about how to detect this, please make a php file just like this:
<?php
phpinfo();
?>
That script will list the whole config of your php. Search if there is any of domxml or simplexml. If that exists, means that you can use either one.
Hope that helps.



--
Mike FN
&quot;8 out of 10 Owners who Expressed a Preference said Their Cats Preferred Web Programmer.&quot;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top