-
If you could NOT have nested tags this would not be really all that difficult. Tedious, but not difficult. However, as you CAN nest tags, this vastly increases the logic statements required.
Can be done, but would be SO tedious...it becomes difficult.
Essentially, take just a piece your sample. I have adjusted the presentation of it to try and make this easier to read. And let's pretend that the first <Amend> is the beginning of the doc.
<Amend>
<Date>{07/12/2005}7.12.2005</Date>
<ANo>A6-0317</ANo>/
<NumAm>49</NumAm>
</Amend>
OK, say you are testing for <Amend> to see if it has a proper </Amend>.
1. Go to the start of the doc.
2. Find the first tag. Search for any text enclosed by < >.
3. Make a string variable for that. Could use wildcards as well.
4. Search forward text for this variable, but with the added "/".
5. Search BACK to see if there is another instance of the original string.
LOGIC: the issue is how do you trap an instance of a word (a string) between other strings.
A:
<Amend> text text <Amend>
<Date>textext<Date> <Amend>texttext</Amend> WRONG
B:
<Amend> text text </Amend>
<Date> textext<Amend>text text </Amend> WRONG
So say you search for a tag PLUS that tag again with closing character in it.
In A you end with the </Amend at the end of this snippet - with tags in between. What do you do? You have to search THOSE tags logically. Is one of them another <Amend>? Is it the first one? If so, then THAT one needs the closing "/".
Now another choice. Do you continue to determine the logic decisions for this initial chunk? In other words, do you do the logic testing for the OTHER tags - in this case, <Date>? Or do you finish with the original tag - this case <Amend>?
In B you end up with the correct closing tag - [b]with NO tags in between. But how do you know that? You don't. The most important point being is that one of them may be another <Amend> (or the original tag, whatever it is you are testing). If it is - then that is probably...but may not be...you are going to have to test...the closing tag.
So...you gotta check.
Do you see what I mean. Yes, this could be done. There may be more efficient ways of going about it. Likely there are. Still, it is an issue of the ....booooorrrrrring..tediousness of doing it.
Mind you, if you have a lot of this to do, well it may be worth it.
Last edited by fumei; 01-12-2006 at 07:05 PM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules