Tagdata() not working for more than 1 tag occurence


#1

I have a procedure that uses tagdata(). My document contains tags like this.

<Special>
<SomeTagsBefore></SomeTagsBefore>
<Description>My Description 1</Description>
<OtherTags1></OtherTags1>
<OtherTags2></OtherTags2>
<OtherTags3></OtherTags3>
</Special>

<NotSoSpecial>
<SomeTagsBefore></SomeTagsBefore>
<Description>MyDesription2</Description>
<OtherTags1></OtherTags1>
<OtherTags2></OtherTags2>
<OtherTags3></OtherTags3>
</NotSoSpecial>

My procedure is

variable=array build(cr(),{tagdata(mData, "<Description>", "</Description>", 1)+";"+tagdata(mData, "   <Description>", "</Description>", 2)},{selection criteria})

The Result is correct for the 1st occurence, but the second one starts with the tag for the 2nd occurence and includes every other tag after. So with my example above my results look like this.

MyDescription1;</Description>
<OtherTags1></OtherTags1>
<OtherTags2></OtherTags2>
<OtherTags3></OtherTags3>
</NotSoSpecial>

Thoughts?


#2

You haven’t really supplied enough information such that anyone else could duplicate your results. I did some tests on tagdata(, however, and it was able to correctly retrieve more than one tag occurrence. I tried the data you supplied above and had no problem extracting the second occurrence.

I don’t see how your second tagdata( function works at all. since there are several extra blanks in front of <description>.


#3

The blanks were a post oops, it is not in the original code. I will email you one record I am using, I just tried it again and same weird result.


#4

It turns out tagdata() function does have a bug if you have a tag that doesn’t contain any text.


#5

Is there a work around for this until the bug is fixed?


#6

Since arrays now allow you to use more than one character as a separator, you could use the tags as separators.

tagdata(mData, "<Description>", "</Description>", 1)+";"+tagdata(mData, "   <Description>", "</Description>", 2)

could be written as

array(array(mData,2,"<Description>"),1,"</Description>")+";"+array(array(mData,3,"<Description>"),1,"</Description>")