Long String

Hello, how can I get part of long string? example: str50:=’ Import Field: '+copyStr( (NewChild.XML),1,50); this code cause error if NewChild.XML long string

Se21, As i see you are trying to copy the text ‘Import Field’ + 50 characters into the field str50 which has only place for 50 characters.If you want to copy the text ‘Import Field’ aswell you should change the length of str50 to str65. Regards, Wendy.

Sorry, bag example. Please consider this new message(’ Import Field: ‘+copyStr( (NewChild.XML),1,50) ); this code cause error if NewChild.XML - long string or str250:=’ Import Field: '+copyStr( (NewChild.XML),1,50); where str250 - Text[250] error if NewChild.XML - long string too

The IXMLDOMText object has a ‘substringData’ method that lets you get at the text chunks at a time… IF NewChild is an XMLDOMNode whose xml property looks like this:

<elementName>very long text string stored here...</elementName>

then do the following: Declare xmlText as Automation, ‘Microsoft XML, v4.0’.IXMLDOMText.

// get the text of the current element... xmlText := NewChild.firstChild; // show just the first 50 chars of the text... str250 := 'Import Field: ' + xmlText.substringData(1,50);

Thanks, Fritz. It’s work fine! But if NewChild.firstChild is XML element xmlText := NewChild.firstChild not work. How can we get part of long sring from Automation?

Ok, how about something like this: Declare adoStream as Automation, ‘Microsoft ActiveX Data Objects 2.8 Library’.Stream;

... CREATE(adoStream); adoStream.Type(2); //adTypeText adoStream.Charset('UTF-8'); adoStream.Open; xmlDOMDoc.save(adoStream); adoStream.Position(0); WHILE (NOT adoStream.EOS) DO BEGIN MyText := adoStream.ReadText(250); MESSAGE(MyText); END; ...

Yes! This is OK.