Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. XML / XSL
  4. Xml as argument in JS

Xml as argument in JS

Scheduled Pinned Locked Moved XML / XSL
javascripthtmlxmlhelpquestion
5 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • O Offline
    O Offline
    Ollie1986
    wrote on last edited by
    #1

    Hey, I have a HTML document with a lot of (random placed) XML -files in a table. Now if a field has more then 100characters I want to open it in a popup (with a button) but! because my XML-files contain quotes and so it gives errors. How can u solve this problem? thx!

    D 1 Reply Last reply
    0
    • O Ollie1986

      Hey, I have a HTML document with a lot of (random placed) XML -files in a table. Now if a field has more then 100characters I want to open it in a popup (with a button) but! because my XML-files contain quotes and so it gives errors. How can u solve this problem? thx!

      D Offline
      D Offline
      Dmitry Khudorozhkov
      wrote on last edited by
      #2

      Solution is simple: escape your XML data before showing. Escaping converts " symbols to " sequence. Look at the escape function in JS reference.

      ------------------------- Don't worry, be happy :o)

      O 1 Reply Last reply
      0
      • D Dmitry Khudorozhkov

        Solution is simple: escape your XML data before showing. Escaping converts " symbols to " sequence. Look at the escape function in JS reference.

        ------------------------- Don't worry, be happy :o)

        O Offline
        O Offline
        Ollie1986
        wrote on last edited by
        #3

        there is the problem, you cant give quote as parameter in a Javascript And you are saying to escape it with a javascript... thx!

        D 1 Reply Last reply
        0
        • O Ollie1986

          there is the problem, you cant give quote as parameter in a Javascript And you are saying to escape it with a javascript... thx!

          D Offline
          D Offline
          Dmitry Khudorozhkov
          wrote on last edited by
          #4

          Just looked in MSDN - escape isn't that method, sorry... This function helps me:

          function escapeString(str)
          {
          var escAmpRegEx = /&/g;
          var escLtRegEx = //g;
          var quotRegEx = /"/g;
          var aposRegEx = /'/g;

          str = str.replace(escAmpRegEx, "&");
          str = str.replace(escLtRegEx, "<");
          str = str.replace(escGtRegEx, ">");
          str = str.replace(quotRegEx, """);
          str = str.replace(aposRegEx, "'");
          
          return str;
          

          }

          After using it, str will not contail any illegal chars.

          ------------------------- Don't worry, be happy :o)

          O 1 Reply Last reply
          0
          • D Dmitry Khudorozhkov

            Just looked in MSDN - escape isn't that method, sorry... This function helps me:

            function escapeString(str)
            {
            var escAmpRegEx = /&/g;
            var escLtRegEx = //g;
            var quotRegEx = /"/g;
            var aposRegEx = /'/g;

            str = str.replace(escAmpRegEx, "&");
            str = str.replace(escLtRegEx, "<");
            str = str.replace(escGtRegEx, ">");
            str = str.replace(quotRegEx, """);
            str = str.replace(aposRegEx, "'");
            
            return str;
            

            }

            After using it, str will not contail any illegal chars.

            ------------------------- Don't worry, be happy :o)

            O Offline
            O Offline
            Ollie1986
            wrote on last edited by
            #5

            I have escaped it in C# before it's written now thx!

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups