Results 1 to 6 of 6

Thread: Auto encode/decode html entities when using XMLReader/Writer?

  1. #1
    Ext JS Premium Member
    Join Date
    Aug 2009
    Posts
    33

    Default Auto encode/decode html entities when using XMLReader/Writer?

    Hello,

    is there a way to automatically encode the values of a record when using an XMLWriter and automatically decode the values of a record when using an XMLReader?

    Currently, if you have a record with the value '> hi <' and save it to an XML-File, you couldn't read the file again, because it's invalid.

  2. #2
    Sencha - Community Support Team jsakalos's Avatar
    Join Date
    Apr 2007
    Location
    Slovakia
    Posts
    27,664
    Answers
    512

    Default

    Is such xml valid?

    (I do not see any such option in XML reader)
    Jozef Sakalos, aka Saki

    Education, extensions and services for developers at new http://extjs.eu
    News: Grid MultiSearch Plugin, Grid MultiSort Plugin, Configuring ViewModel Hierarchy


  3. #3
    Ext JS Premium Member
    Join Date
    Aug 2009
    Posts
    33

    Default

    Quote Originally Posted by jsakalos View Post
    Is such xml valid?

    (I do not see any such option in XML reader)
    No, it isn't valid, because it looks like that:
    Code:
    <element>> hi <</element>
    So I'm looking for an easy way to encode/decode the data before writing/reading it. I've studied the source code of XMLWriter/Reader but I didn't find a good place for an extension.

  4. #4
    Sencha - Community Support Team jsakalos's Avatar
    Join Date
    Apr 2007
    Location
    Slovakia
    Posts
    27,664
    Answers
    512

    Default

    I would rather go the direction of making the xml valid.
    Jozef Sakalos, aka Saki

    Education, extensions and services for developers at new http://extjs.eu
    News: Grid MultiSearch Plugin, Grid MultiSort Plugin, Configuring ViewModel Hierarchy


  5. #5
    Ext JS Premium Member
    Join Date
    Aug 2009
    Posts
    33

    Default

    Quote Originally Posted by jsakalos View Post
    I would rather go the direction of making the xml valid.
    I think you have misunderstood me.
    If you have a store which contains a record and the record has a field 'nickname' with the value '>>Tom<<'.

    XMLWriter creates following output:
    ...
    <nickname>>>Tom<<</nickname>
    ...

    And of course, this is invalid xml. Certainly you can save the user input only encoded to the store. But I don't want to specify this on every input field. So I thought XMLReder/Writer would be the better place for that.

  6. #6
    Sencha - Community Support Team jsakalos's Avatar
    Join Date
    Apr 2007
    Location
    Slovakia
    Posts
    27,664
    Answers
    512

    Default

    You're maybe right, however, there is no encoding/decoding function in XMLReader/Writer so you need to code it.
    Jozef Sakalos, aka Saki

    Education, extensions and services for developers at new http://extjs.eu
    News: Grid MultiSearch Plugin, Grid MultiSort Plugin, Configuring ViewModel Hierarchy


Posting Permissions

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