0

I am wanting to create and save, to the server, an xml file. I understand I should use javascript but am not sure exactly how to code it.

Scenario: I have a php page with variables, $firstname and $lastname for example. So in the php: $firstname = "John"; $lastname ="Doe";

I want to have a javascript that when fired will create and save an xml file.

I found the below post and it got me headed in the right direction.

How to save XML using PHP

Can anyone help me. I greatly appreciate some direction.

Additionally is it possible to have it outputjust like :

<?xml version="1.0" encoding="UTF-8"?>
<form1>
   <fname>John</fname>
   <lname>Doe</lname>
</form1>
1
  • 1
    Why do you want to use Javascript if you can do it with PHP? Besides, Javascript won't be able to save the file. Only your server-side (PHP) can do that. Commented May 5, 2016 at 17:19

1 Answer 1

0

Javascript is a client-side technology, PHP is server side. The question you linked is a good place to start, you'll want to use DomDocument and/or simplexml. If there is client side interaction, you'll still have to post the data to the server and store the file there.

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

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.