basically what i am doing is building a c# app which allows users to open up html files and in between the certain tags find the contents.

So it has to:
- read start tag, example: <object>
- read stop tag, example: </object>
- take text which is in between the two tags and place it in a
text area.
any ideas???

Recommended Answers

All 3 Replies

psuedocode time!

assuming tag opener is "<" and tag closer is ">" and wanted tag is [any tag you want to read the contents of]
Read every character as 'c':
  if c is tag opener:
    read d from c until d is tag closer
    if string(c+, d) is wanted_tag:
      read e from d until e s tag opener:
      return string(d+, e)

Of course, you can do some extra checking on that last part to make sure the encountered tag is actually the closer for your wanted tag, and not just some random < or a tag opener for a nested tag.

Yes that is the problem seeing if there are other tags in the text i want
I know how to get to a tag and parsing the value of that tag, but i am still getting confused what to do when one of the characters is '<' which belongs to a different tag

That's a design decision that you have to make. Do you skip over those internal tags, do you complain to the user, or do you return the text as is?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.