title: How to add element and attribute to xml file in jQuery?
body: <p>I want to get name and email from form and write to xml file exists on the server.I have searched on the internet but I can't do that. Anyone who can give me the code.</p>
  
  <p>xml format:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;Infos&gt;
  &lt;Info name="name" email="email" /&gt;
  &lt;/Infos&gt;
  </code></pre>
  
  <p>The code is better if it is generalized. My code:</p>
  
  <pre><code> &lt;html&gt;
  
  &lt;head&gt;
      &lt;title&gt;Test&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;script src="http://code.jquery.com/jquery-1.12.0.min.js"&gt;&lt;/script&gt;
  &lt;script&gt;
      function addData(fileName, targetName, elementName, attribute, value)
      {
          $.ajax({
              type: "POST",
              url: filename,
              dataType: "xml",
              success: function (xml) {
                  $("&lt;"+elementName+" "+attribute+"="+value+"/&gt;").appendTo($(xml).find(targetName));
              }
          }); 
       }
  &lt;/script&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>