Click here to Skip to main content
15,906,467 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Is their any way to update xml from Jquery or Javascript

I want to set couter on each click

JavaScript
function SetCount() {
           $.ajax({
               url: 'DownloadCount.xml', // name of file you want to parse
               dataType: "xml", // type of file you are trying to read
               success: parse, // name of the function to call upon success
               error: function() { alert("Error: Something went wrong"); }
           });
           function parse(document) {

               $(document).find('apk').each(function() {

             $(this).find('count').text("30");


               });


           }

i am stuck at point how to update original file without code behind
Posted

1 solution

XML or HTML? The Javascript document represents the HTML DOM document. Of course you can generate some HTML as XML document.

I have no idea how this question is related to "setting a counter" or your code, but "update XML" simply means creating some string with XML content based on some existing XML content. If you have some XML text, you parse the whole thing, do some modifications and generate the whole content as a new string.

If you want to work with HTML DOM (I still cannot be sure), it is already parsed since loaded. If you need to parse some XML from scratch, there is a jQuery parser: https://api.jquery.com/jQuery.parseXML[^].

On generation of XML, please see:
http://oreilly.com/pub/h/2127[^],
http://stackoverflow.com/questions/7152064/how-to-create-xml-file-with-jquery[^],
http://stackoverflow.com/questions/3191179/generate-xml-document-in-memory-with-javascript[^].

—SA
 
Share this answer
 
Comments
Abhinav S 2-May-14 12:55pm    
5.
Sergey Alexandrovich Kryukov 2-May-14 13:46pm    
Thank you, Anhinav.
—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900