Use an existing library supporting that specific language: for example a library to parse XML.
Building your own custom parser by hand.
A tool or library to generate a parser: for example ANTLR, that you can use to build parsers for any language.
Use an Existing Library
The first option is the best for well known and supported languages, like XML or HTML. A good library usually also includes APIs to programmatically build and modify documents in that language. This is typically more of what you get from a basic parser. The problem is that such libraries are not so common and they support only the most common languages. In other cases, you are out of luck.