Error Converting XML to CDT using torecord() function.

Certified Senior Developer

I am getting the below-mentioned error while converting xml to cdt using torecord() function. 

Does any one know what is the root cause of this error ?? or Let me know alternatives of converting XML to CDT ?

Thanks

  Discussion posts and replies are publicly visible

Parents Reply
  • 0
    Certified Lead Developer
    in reply to Akash Chalamcharla

    Where is the XML getting generated?  The text being passed into the XML's data will need to be sanitized so that parsing it later doesn't break (similar things happen, for instance, if these unsanitized characters are passed into the MS Word from Template smart service).  The sanitization rule I always use looks something like this:

    a!localVariables(
      local!characters: {
        "&",
        ">",
        "<",
        """", /* quote */
        "'", /* apostrophe */
        char(10),
        char(13)
      }, /* the ordering of these is important. */
    
      local!replacements: {
        tohtml("&"),
        tohtml(">"),
        tohtml("<"),
        "\&\quot;",
        "\&\apos;",  -- note: backslashes added here just to post on Community
        "\&\#10;",
        ""
      },
    
      reduce(
        fn!substitute,
        trim(ri!input),
        a!forEach(
          local!characters,
          {
            fv!item,
            local!replacements[fv!index]
          }
        )
      )
    )

Children
No Data