im making a program that has alot to do with text replaces ment and im not good at all that stuff so can some one help me out . i got two question

1) How can i replace the text and then replace it with something else

ex
<title> hehehehehhehe </title>
<title> replace that </title> ' with out making a new title tag

2) how can i get the text that is inside the tags

ex
<title> hehehehhehehhehe </title>
teh title is heheheheheheheh


if any one anwser's just one it will be very nice i now this text stuff is hard thank you