-1

Possible Duplicate:
A simple program to CRUD node and node values of xml file

So I have this code, which is located in settings.xml:

<?xml version="1.0"?>
<settings>
    <user id="140">
        <about>About me</about>
        <music>My music</music>
        <interests>My interests</interests>
        <font>Arial</font>
        <theme>Default</theme>
    </user>
</settings>

and I want to replace the content of about ('About me') with lets say ('This is about me') and then save it to the original file, so after that it will include the following:

<?xml version="1.0"?>
<settings>
    <user id="140">
        <about>This is about me</about>
        <music>My music</music>
        <interests>My interests</interests>
        <font>Arial</font>
        <theme>Default</theme>
    </user>
</settings>

How is that possible to do using PHP? I've tried some things but they didn't work as expected.

Community
  • 1
  • 1
Systemfreak
  • 327
  • 7
  • 13

1 Answers1

0

Use SimpleXML for easy reading trough XML files and you can edit the text like editing a variable value. For get an element with an id of 140 you need to use XPath, some explaination.

Community
  • 1
  • 1
Wouter J
  • 41,455
  • 15
  • 107
  • 112