My goal is to scan a file and check whether the given file is well-formed or not.
for example
Code:<test> <yeah> <yahoo> bla blabla </yahoo> </yeah> what ever <s> it is </s> <br/> test </test>
i have parsed every single tag into the stack now I'm at the point where I have to check whether all the tag is paired except the tag without closing like <br/>
now my stack look like the following
[8] = </test>
[7] = <br/>
[6] = </s>
[5] = <s>
[4] = </yeah>
[3] = </yahoo>
[2] = <yahoo>
[1] = <yeah>
[0] = <test>
.......
and so on.
Can you guys help me good algorithm to check whether or not all the tag is paired.
I'm not expecting the code to make this happen and I'm sure you won't give that to me, I just need good algorithm or steps that can make this happen. Been thinking for quite sometime but I cant figure the easy way to do this.
Thank you in advance




Reply With Quote