Create and save a XML file using jquery

10 posts, 0 answers
  1. THIYAGARAJAN
    THIYAGARAJAN avatar
    15 posts
    Member since:
    Apr 2013

    Posted 15 Apr 2013 Link to this post

    Create and save a XML file using jquery, can any one give suggestions for this, how to do in mobile app.
  2. Jan-Dirk
    Jan-Dirk avatar
    327 posts
    Member since:
    Jun 2012

    Posted 15 Apr 2013 Link to this post

    As far as I know you can't create an xml file on 'disk' (or other media) with JavaScript, only in memory.
  3. THIYAGARAJAN
    THIYAGARAJAN avatar
    15 posts
    Member since:
    Apr 2013

    Posted 15 Apr 2013 Link to this post

    Can u say, how to create in memory in javascript/jquery. would you any site reference for this..
  4. Prabu
    Prabu avatar
    4 posts
    Member since:
    Apr 2013

    Posted 15 Apr 2013 Link to this post

    can we  write values to xml file using jquery?if possible give me examples.
    thanks.
  5. Jan-Dirk
    Jan-Dirk avatar
    327 posts
    Member since:
    Jun 2012

    Posted 15 Apr 2013 Link to this post

    http://stackoverflow.com/questions/7152064/how-to-create-xml-file-with-jquery
  6. THIYAGARAJAN
    THIYAGARAJAN avatar
    15 posts
    Member since:
    Apr 2013

    Posted 15 Apr 2013 Link to this post

    can you say, how to save xml file in memory, can you give any reference for that
  7. Jan-Dirk
    Jan-Dirk avatar
    327 posts
    Member since:
    Jun 2012

    Posted 15 Apr 2013 Link to this post

    I am sorry, but I haven't used it myself.

    Please use Google :)

    The 4th reply (by 'jiggy') in the page I linked to earlier gives you some pointers where to search for.
  8. Deepan
    Deepan avatar
    19 posts
    Member since:
    Oct 2013

    Posted 10 Jan 2014 Link to this post

    Hi, guys i am working in Jquery mobile

    it is possible to store xml file using jquery in both Android and Iphone

     var content = '<?xml version="1.0" encoding="UTF-8"?>';
     content+='<logins>';
     content +='<properties>'
     content +='<username>something</username>'
     content +='<password>something</password>'
     content +='</properties>'
     content +='</logins>';

    var  storedFileName = "login.xml";
    var storedContent = content;
       StoreLocalXML();


      /* Create Local Xml Files */
        function StoreLocalXML() {
            window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, gotFS, Fail);
        }
     
        function gotFS(fileSystem) {
            // create dir
            fileSystem.root.getDirectory("folderName", {
                create: true,
                exclusive: false
            }, gotDirEntry, Fail);
        }

        function gotDirEntry(dirEntry) {
            // create file
            dirEntry.getFile(storedFileName, {
                create: true,
                exclusive: false
            }, gotFileEntry, Fail);
        }

        function gotFileEntry(fileEntry) {
            fileEntry.createWriter(gotFileWriter, Fail);
           
        }

        function gotFileWriter(writer) {
               
            writer.onwrite = function (evt) {
                console.log("write completed");
            };
            writer.write(storedContent);
            writer.abort();
          
        }

        function Fail(error) {
            console.log(error.code);
        }
  9. tra12
    tra12 avatar
    1 posts
    Member since:
    Jun 2014

    Posted 17 Jun 2014 in reply to Deepan Link to this post

    Hi,

    is it possible to use this code for an android app example.
    actually i am using phonegap and  i have to save some data in xml. 
    to read from xml with jquery is not a problem, only to save....

    thanks in advance

    regards,

    tra12
  10. Tina Stancheva
    Admin
    Tina Stancheva avatar
    3298 posts

    Posted 20 Jun 2014 Link to this post

    Hi tra12,

    You should be able to use the Cordova File API to write your data in an xml file and save it in the file system of a device. The code bellow also demonstrates this API so you can definitely use it and you can also take a look at the AppBuilder File Sample to get started.

    Regards,
    Tina Stancheva
    Telerik
     

    Share what you think about AppBuilder and Telerik Platform with us in our feedback portal, so we can become even better!

     
Back to Top