Announcement

Collapse
No announcement yet.

writing xml tags from DB to xml file

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • writing xml tags from DB to xml file

    I have some xml tags stored in a DB that I am trying to write to file. When I use a DB reader and get these and write them to file, the ">" and "<" of the xml tags are getting replaced by "&gt;" and "&lt;" in the file. This is problematic with the program that is reading it as it doesn't do any parsing to the xml file and just skips over what should be tags..
    this is what the tags are..
    <document>
    <file-name>F810B80C-C292-416C-A62F-EF4A96972696.pdf</file-name>
    </document>
    and they are getting put into the file as:

    &lt;attachement_document&gt;&lt;document&gt;&lt;fi le-name&gt;F810B80C-C292-416C-A62F-EF4A96972696.pdf&lt;/file-name&gt;&lt;/document&gt;&lt;/attachement_document&gt;

    Thanks!

  • #2
    A bit more info would assist us in helping you.

    1. What version of Mirth are you using?

    2. What is the data type of the field these values come from within your database?

    3. How is reading the html encoded string breaking the final program? Are you just using Mirth as a passthru?



    I would approach this issue first by making sure the datatype from the query/sproc is returning XML and not a regular var char.

    could you post your sql from the DB reader and the DB schema for the fields in question.

    you could also attempt a preprocessor script that does a string replace on &gt; with > and &lt; with <. This way your RAW source text will be what you need in the destination.


    Or the first source transformer could be a string replace instead of using the preprocessor script.

    Comment


    • #3
      1. 3.5.1
      2. It was a varchar, I changed it to an xml data type but i am still getting the same problem..
      3. Yes it is just a pass through. I am trying to get an additional couple pieces of info from a database and put those in the xml file. To do this i have created 2 channels. The first channel reads the original xml file and puts the values in a field. The second channel gets the info that i want to add and then writes the file to a new location. Its this second channel that i am having issues with the original xml tags going back into the xml file properly.

      Ive tried using the preprocessor and the replace functions, but it still doesn't show properly..

      If there is a better way to accomplish the described, please let me know i am fairly new to mirth.
      Attached Files

      Comment


      • #4
        I think you might want to wrap that XML column around a CDATA tag.
        HL7v2.7 Certified Control Specialist!

        Comment


        • #5
          Originally posted by dmro View Post
          I have some xml tags stored in a DB that I am trying to write to file. When I use a DB reader and get these and write them to file, the ">" and "<" of the xml tags are getting replaced by "&gt;" and "&lt;" in the file. This is problematic with the program that is reading it as it doesn't do any parsing to the xml file and just skips over what should be tags..
          this is what the tags are..
          <document>
          <file-name>F810B80C-C292-416C-A62F-EF4A96972696.pdf</file-name>
          </document>
          and they are getting put into the file as:

          &lt;attachement_document&gt;&lt;document&gt;&lt;fi le-name&gt;F810B80C-C292-416C-A62F-EF4A96972696.pdf&lt;/file-name&gt;&lt;/document&gt;&lt;/attachement_document&gt;

          Thanks!
          &lt; (<), &amp; (&), &gt; (>), &quot; ("), and &apos; (') are encoding
          or special characters of XML and cannot be printed directly in the Document Writer. You need to replace them with the defined characters and they will print correctly.

          You can replace them in the Preprocessor like:

          message = message.replace(/&/g, '&amp;');
          message = message.replace(/</g, "&lt;");

          You can replace the characters you need.

          Comment


          • #6
            writing xml tags from DB to xml file

            Hi please help me

            how can I use this script

            message = message.replace(/&/g, '&amp;');
            message = message.replace(/</g, "&lt;");


            I have this
            Mapping: msg['examenid'].toString()

            its content in a database is XML

            <examenid>903871</examenid><examenid>903816</examenid>

            but read the following

            <examenid>903818&lt;903816&lt;903815&lt;903868&lt; 903842&lt;</examenid>

            Thank you friend for your help

            Mirth connect version 3.7.0

            Comment


            • #7
              Originally posted by Thoughts_Shared View Post
              &lt; (<), &amp; (&), &gt; (>), &quot; ("), and &apos; (') are encoding
              or special characters of XML and cannot be printed directly in the Document Writer. You need to replace them with the defined characters and they will print correctly.

              You can replace them in the Preprocessor like:

              message = message.replace(/&/g, '&amp;');
              message = message.replace(/</g, "&lt;");

              You can replace the characters you need.
              Hi Friend
              can you tell me how to use that expression in mapping?

              Thank you for reply

              Comment

              Working...
              X