how to read long text in XML node

scottscott Member Posts: 76
I got an error "the length of text string exceeds the size of the string buffer" when executing this:

textvariable := XMLNode.attributes.getNamedItem('Note').text

I guess we can assign the node value to instream. But not sure the correct syntex.

Does anyone have any idea?

Thanks.

Scott

Comments

  • jhoekjhoek Member Posts: 216
    Please search this forum before posting a question - it has been answered several times before.
    BTW, check out the IXMLDOMCharacterData interface. :)
    Kind regards,

    Jan Hoek
    Product Developer
    Mprise Products B.V.
  • scottscott Member Posts: 76
    I searched both the forum and website on IXMLDOMCharacterData. Still did not find good answer.

    In the attribute of a node, there can be a few thousand characters. We need to get all characters, not just first 250.

    Do you have any sample codes?

    Thanks

    Scott
  • Morten_SolbergMorten_Solberg Member Posts: 24
    search in the forum: *xmldom*
  • LoberLober Member Posts: 2
    Try "BSTR that exceeds string buffer length" 17/08/2006
  • scottscott Member Posts: 76
    Thanks. "BSTR that exceeds string buffer length" 17/08/2006 does have a useful solution.

    For some reasons, 'Navision Attain Hash 1.0'.BSTRConverter deletes line return characters, so output is not very clean...

    I wrote a VB 6 dll program to take care of this. You can specify maximum characters per line. It cuts notes between words, and retains line return characters.

    Codes in Navision...

    HeaderNoteFileName := FileRec.Path + '\Note\' + FileRec.Name + '.TXT';

    IF MYDLL.DownloadNote(XMLNode.attributes.getNamedItem('Note').nodeValue,HeaderNoteFileName,MaxCharacterPerLine) = 'OK'
    THEN BEGIN
    HeaderFile.OPEN(HeaderNoteFileName);
    HeaderFile.TEXTMODE := TRUE;

    ReadOK := TRUE;
    HeaderCommentLineNo := 0;

    WHILE ReadOK DO BEGIN
    IF HeaderFile.READ(MessageLine) <> 0 THEN BEGIN
    HeaderCommentLineNo += 10000;
    TempSalesCommentLine.INIT;
    TempSalesCommentLine."Document Type" := TempSalesCommentLine."Document Type"::Quote;
    TempSalesCommentLine."No." := TempSalesHeader."No.";
    TempSalesCommentLine."Line No." := HeaderCommentLineNo;
    TempSalesCommentLine.Date := WORKDATE;
    TempSalesCommentLine.Comment := MessageLine;
    TempSalesCommentLine.INSERT;
    END ELSE
    ReadOK := FALSE;
    END;
    END;


    Codes in VB 6...

    Public Function DownloadNote(ByVal NoteMessage As Variant, ByVal FileName As String, ByVal MaxCharacters As Integer) As String
    On Error GoTo errorHandler
    Dim String1 As String
    Dim x As Integer

    If NoteMessage = "" Then
    Exit Function
    End If

    Open FileName For Output As #1

    Do Until NoteMessage = ""
    String1 = Left$(NoteMessage, MaxCharacters)

    For x = 1 To Len(String1)
    If InStr(Right$(String1, x), " ") <> 0 Then
    Exit For
    End If
    Next x

    String1 = Left$(String1, MaxCharacters - x)
    NoteMessage = Mid(NoteMessage, MaxCharacters - x + 2):
    Print #1, String1
    Loop

    Close 1

    DownloadNote = "OK"

    Exit Function
    errorHandler:
    Err.Raise -12345678, "HttpPost", Err.Description
    End Function
  • scottscott Member Posts: 76
    thansk for everyone's help.
Sign In or Register to comment.