I am trying to translate a page in PHP using Google API. There is 5000 chars limit on data that you can send to Google at a time. So I am trying to break the page into pieces of 5000 chars. But as you know while doing this we have to keep in mind the HTML formatting that it should not be disturbed otherwise you will not get desired results.
For example you have to send this:
<a href="#" class="myclass">Link</a>
Instead of this:
<a href="#" class="myclas
I am able to solve it somehow (although not perfectly I guess) by checking if "<" sign is coming after ">" sign or not. If "<" sign is coming after ">" then I go back to the point where I found ">" and cut string from there.
Anyway the point is I am still having some problems regarding HTML formatting and want to know how to do it efficiently. Is there any parser available that will solve this problem!?