XML Export large strings

FPulsfortFPulsfort Member Posts: 43
Hi,

i need to export a long string to a xml-file. The string contains about 5000 and more characters. When i use a xml-port i get an error message that the string is to long. I've created an element and try to assign the text to this element with e.g. 5 Textvariables each containing 1024 characters. But i get the above mentioned error. When i try to use automation i will get an error that my stack is not large enough.

Can anyone point me to the right direction?

Regards,
Frank

Comments

  • DenSterDenSter Member Posts: 8,304
    Using an XMLPort and a XMLDOM object it should not be a problem
  • FPulsfortFPulsfort Member Posts: 43
    Thanks for your answer, Denster.

    i tried both but without success. First i use an xmlport. I inserted a tag teststring with tagtype text. Then i assign 10 Textvariables to the tag like
    teststring := Text1 + Text2 + ... + Text10;
    When i run the xmlport i get an error that the string is too long for teststring

    then i tried to use 'Microsoft XML, v3.0'.IXMLDOMNode. But when i try the same with XMLDomNode,
    XMLNode.Text := Text1 + Text2 + ... + Text10;
    i get the same error message.

    Can you give me an example how to handle this, please?

    Thanks and kind regards,
    Frank
  • DenSterDenSter Member Posts: 8,304
    An XMLPort builds an XML document based on a NAV table, so al you have to do is send in a record. Check out the XML codeunits in the standard Biztalk functionality, and you'll find some examples of how to do that.
  • SilverXSilverX Member Posts: 134
    Try changing the property of the XMLport text field to BigText and use the ADDTEXT method.
    Cheers
    Carsten


    ==> How To Ask Questions The Smart Way

    This post is my own opinion and does not necessarily reflect the opinion or view of my employer.
  • ara3nara3n Member Posts: 9,255
    Hello. You can't use xml dom because of 250 limit to COM in navision.
    You can use xmlports. here is an example.
    OBJECT XMLport 50001 test
    {
      OBJECT-PROPERTIES
      {
        Date=04/30/07;
        Time=[ 8:39:10 PM];
        Modified=Yes;
        Version List=;
      }
      PROPERTIES
      {
      }
      ELEMENTS
      {
        { [{F174CB18-55F2-4B26-AFEC-D03684586883}];  ;item                ;Element ;Table   ;
                                                      VariableName=Item;
                                                      SourceTable=Table27 }
    
        { [{EA1C7685-B63B-4ACA-9C7D-37B6F68258D5}];1 ;No                  ;Element ;Field   ;
                                                      DataType=Code;
                                                      SourceField=Item::No. }
    
        { [{82C87225-3CA3-4990-9ECF-E976336175C7}];1 ;LargeText           ;Element ;Text    ;
                                                      Import::OnAfterAssignVariable=BEGIN
                                                                                      Item.Description := COPYSTR(LargeText,1,30);
                                                                                      Item."Description 2" := COPYSTR(LargeText,30,30);
                                                                                      //Item.modify;
                                                                                    END;
                                                                                     }
    
      }
      EVENTS
      {
      }
      CODE
      {
    
        BEGIN
        END.
      }
    }
    
    
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • pdjpdj Member Posts: 643
    ara3n wrote:
    You can't use xml dom because of 250 limit to COM in navision.
    That is not correct. I have done it using the appendData method. (Or something simular, I'm quite sure about the "append" part of the name). I just don't recall for which customer, but let me know if it doesn't help you in the right direction - then I might be able to dig up the database.
    It is both possible to read and write elements bigger than 250 char directly with xmldom from C/AL. Now I think of it, I remember making a Base64 encoder and decoder in C/AL and was able to transfer binary files to/from CDATA sections.
    Regards
    Peter
  • DenSterDenSter Member Posts: 8,304
    ara3n wrote:
    Hello. You can't use xml dom because of 250 limit to COM in navision.
    No that it not correct. I have successfully used XMLDOM objects for very large xml documents, definately larger than 250 characters.
  • ara3nara3n Member Posts: 9,255
    DenSter wrote:
    ara3n wrote:
    Hello. You can't use xml dom because of 250 limit to COM in navision.
    No that it not correct. I have successfully used XMLDOM objects for very large xml documents, definately larger than 250 characters.

    What I mean is any function that returns a string that is greater than 250 will error out.
    For example XMLNode.text can return a string that is greater than 250 and you'll get the error.

    the XMLNode.appenddata doesn't have appenddata.

    For example

    You cannot read the following xml file with xmldom.
    <?xml version="1.0" encoding="UTF-16" standalone="no"?>
    <item>
    	<No>ha002</No>
    	<LargeText>1111111111111111111111122222222222228888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888882222222222222222222234444444444444444222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222224444</LargeText>
    </item>
    
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • DenSterDenSter Member Posts: 8,304
    Sure that will fail, due to maximum variable length in the app for individual element values. But you CAN have a wellformed XML text string that is longer than 250 loaded into an XMLDOM object. I've loaded hundreds of Items in one XML document and successfully imported them into NAV with an XMLPort.
  • pdjpdj Member Posts: 643
    ara3n wrote:
    You cannot read the following xml file with xmldom.
    Am I really the only one who have done that with success? :?
    You can read unlimited nodevalues, but not using xmlnode.text. Take a look at the substringData method...

    Well, seems time to make an example for he Tips'n Tricks section 8)
    Regards
    Peter
  • FPulsfortFPulsfort Member Posts: 43
    Hello SilverX,

    That it. Now it works.

    Thanks for all your answers.

    Regards,

    Frank
Sign In or Register to comment.