0

I am trying to insert data into xml file. For Ex:

<list>
    <activity>swimming</activity>
    <activity>running</activity>
</list>

In place of swimming i want to insert different data(ex:jogging) How can i do that?

4
  • There is an edit button near bottom left corner of the question - use it to update your existing questions instead of posting a new one. Select your code and hit ctrl-k for formatting it. more formatting tips Commented Jul 14, 2010 at 6:19
  • @Amarghosh Thanks for posting that link. It will soon become my favorite link to post in comments, I'm certain. Commented Jul 14, 2010 at 6:38
  • possible duplicate of Inserting data in XML file with PHP DOM Commented Jul 14, 2010 at 7:17
  • possible duplicate of php code to inset data into xml file Commented Jul 14, 2010 at 7:41

1 Answer 1

1

Use a PHP XML library, such as http://php.net/manual/en/book.simplexml.php . Unfortunately, when you're modifying an XML document with a simple interface, you often have to regenerate the document. If you use a stream-based processor you may be able to avoid this.

Sign up to request clarification or add additional context in comments.

2 Comments

I got simplexml for only reading..Actually i want to insert data into xml file. can u please send the code
@kavita123: You're asking me to spend my time writing code so that you don't have to?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.