×

Discussion Board

Results 1 to 4 of 4
  1. #1
    Regular Contributor
    Join Date
    Apr 2003
    Location
    Akron Ohio USA
    Posts
    229

    problem with parseFromString

    I am experimenting with the idea of storing structured data in an xml file in a persistent variable (setPreferenceForString).

    I will retreive the xml file using getPreferencesFromString and parse it into javascript variables.

    My first attempt is to use the DOMParser and parseFromString:

    var parser = new DOMParser();
    var doc = parser.parseFromString("<test>test</test>","text/xml");
    alert(doc);

    However, the parseFromString line causes the s60 3rd edition fp2 1.1 emulator to close the WRT application. It is ok with the DOMParser object declaration statement but does not seem to support parseFromString. Are there any work arounds for this or are there any other xml apis that I can use to load an xml from a string (persistent storage) and parse into javascript variables?

  2. #2
    Registered User
    Join Date
    Jan 2009
    Posts
    1

    Re: problem with parseFromString

    I have the same problem. But if you run same code on real phone, it works fine.Could anyone give me some suggestions?

    Thanks!



    Quote Originally Posted by hp3 View Post
    I am experimenting with the idea of storing structured data in an xml file in a persistent variable (setPreferenceForString).

    I will retreive the xml file using getPreferencesFromString and parse it into javascript variables.

    My first attempt is to use the DOMParser and parseFromString:

    var parser = new DOMParser();
    var doc = parser.parseFromString("<test>test</test>","text/xml");
    alert(doc);

    However, the parseFromString line causes the s60 3rd edition fp2 1.1 emulator to close the WRT application. It is ok with the DOMParser object declaration statement but does not seem to support parseFromString. Are there any work arounds for this or are there any other xml apis that I can use to load an xml from a string (persistent storage) and parse into javascript variables?

  3. #3
    Regular Contributor
    Join Date
    Apr 2003
    Location
    Akron Ohio USA
    Posts
    229

    Re: problem with parseFromString

    Quote Originally Posted by jiangjiang0451 View Post
    I have the same problem. But if you run same code on real phone, it works fine.Could anyone give me some suggestions?

    Thanks!
    I ended up using a JSON formatted string. This worked much better because it was very straight forward to simply convert the json string into a javascript object.

    In my case I was generating the json string in my javascript code based upon input from user.

    If you load an xml file then you will be parsing into some javascript variable structure anyway, and it is just one step further to convert javascript object into a json string and save that to the WRT preference variable.

  4. #4
    Regular Contributor
    Join Date
    Jun 2009
    Posts
    103

    Re: problem with parseFromString

    hi hp3

    if you don't have any solution plz use below code:

    var testSTR=yourString.indexOf("<test>")
    var testEND=yourString.indexOf("</test>")
    var resulttest=yourString.substring(testSTR+6,testEND)

    Tarun(TJ)

Similar Threads

  1. Problem with eglSwapBuffers and heap corruption
    By greatape in forum Symbian Media (Closed)
    Replies: 2
    Last Post: 2007-05-24, 03:35
  2. netcards - Problem with opening adapter
    By kernj in forum Symbian Tools & SDKs
    Replies: 5
    Last Post: 2007-01-10, 08:56
  3. WAP service problem on Apache
    By bigg_o in forum Browsing and Mark-ups
    Replies: 3
    Last Post: 2005-04-17, 16:05
  4. Problem: S60 SDK for CW in PC with .NET
    By anttij in forum Carbide.c++ IDE and plug-ins (Closed)
    Replies: 1
    Last Post: 2005-02-28, 11:36

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×