Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Parsing data from One Large Field 2

Status
Not open for further replies.

fcullari

IS-IT--Management
Oct 28, 2002
30
US
I need to parse a field to show all the groups of data in this large field. For example- all the email addresses.

<ROW><EVENT type="C">Task Is Late</EVENT><ACTION type="C">Send
Email</ACTION><PARAMS type="C"><parameters><NUMPARAMETERS>1</NUMPARAMETERS><Caption1>Days
Late</Caption1><Name1>DaysLate</Name1><DaysLate.value>3</DaysLate.value>
<type1>Number</type1></parameters></PARAMS><EXPRESSION
type="C">days_late >= <%poXML.mExtract([dayslate.value])%> and
act_finish='1899-12-30'</EXPRESSION><TARGET
type="C"><NUMPARAMETERS>3</NUMPARAMETERS><Caption1>Emails</Caption1><Name1>email
</Name1><email.value>dliming@maidenform.com</email.value><type1>Text</type1>
<Caption2>Subject</Caption2><Name2>Subject</Name2><Subject.value>Design
Complete</Subject.value><type2>String</type2><Caption3>Message</Caption3>
<Name3>Message</Name3><Message.value>Design
is late, please
provide...</Message.value><type3>Text</type3></TARGET><REPEAT
type="C">0</REPEAT><ID_ITEM type="C">0</ID_ITEM></ROW>


 
All? There's only one email address...

Please provide an example of multiples if they exist.

Do you know your version of Crystal? If it's CR 8.5 or below you're going to have troubles as the limit is 254 for fields used in formulas, and for output from a formula.

Do you know what database you're using? You might use SQL Expressions to parse this large field.

This formula should be close:

stringvar MySTring := {table.field}
Stringvar array Emails;
stringvar curremail;
numbervar counter;
For Counter := 1 to 1000 do(
if instr(Mystring,"<email.value>") <> 0 then
MyString:=mid(Mystring,instr(Mystring,"<email.value>")+13);
Curremail:=left(MyString,instr(MyString,"<")-1);
redim preserve Emails[Counter];
Emails[Counter]:=Curremail;
MyString:=mid(Mystring,instr(Mystring,"<email.value>")+13);
If len(MyString) < 14 then
counter:=1001;
);
join(Emails,",")

-k
 
Does anyone know how to do this using Crystal syntax?
 
Yes, look at the post from 'synapsevampire' above ;)

Seriously, that is[/] Crystal syntax.

-dave
 
Add a semicolon at the end of the following line and then try the above formula:

stringvar MySTring := {table.field};

-LB
 
Thanks for your help it almost helped.

I get this:
fcullari@maidenform.com,denform.com,/email.value>,>,,tion2>Subject,t,,ct,ubject.value>Photo Shoot Date,>Photo Shoot Date, Date,ct.value>,pe2>String,type2>,on3>Message,/Caption3>,ame3>Message,,sage.value>Please provide photo shoot date.,lease provide photo shoot date.,e photo shoot date.,t date.,sage.value>,type3>Text,type3>,ET>,ype="C">0,EPEAT>,EM type="C">0,0

I just want the email addresses that have %@maidenform.com%
Is there a way to do that?
 
Try this. Works for me:

stringvar Search1 := "<email.value>";
stringvar Search2 := "</email.value>";
stringvar str := {Table.Field};
numbervar i := 1;
numbervar pos1 := 0;
numbervar pos2 := 0;
stringvar array Emails;

while i < len(str) do(
pos1 := instr(i, str, Search1);
if pos1 <> 0 then(
pos2 := instr(pos1, str, Search2);
if i = 1 then
ReDim Emails[1]
else
ReDim Preserve Emails[UBound(Emails) + 1];
Emails[UBound(Emails)] := mid(str, pos1 + len(Search1), pos2 - (pos1 + len(Search1)));
i := pos2;)
else
i := i + 1;
);
Join(Emails, ", ");

-dave
 
Here is my take on this:

If there was just one email address, you could do this:
Code:
extractstring({table.field},"<email.value>","</email.value>")

If there could be multiples, then you could use this as another possibility to the others already provided:

Code:
stringvar strBegin := "<email.value>";
stringvar strEnd   := "</email.value>";
stringvar input    := {table.field};
stringvar result   := "";

while instr(input,strBegin) > 0 do
(
    result := result & "," & extractstring(input,strBegin,strEnd);
    html_data := mid(input,instr(input,strEnd)+length(strEnd));
);
mid(result,2);

To work for other tags, simply use the same logic, just replace the values of strBegin and strEnd.

~Brian
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top