Definitely could use some more details on #2. From the code snippet, I gather you are using Selenium web driver? If you are able to supply the content you are retrieving in the browser?
From my experience with Selenium webdriver, using the By.xpath failed for me because I either had the xpath expression wrong for the page -or- the page contained frames and webdriver does not seem to work with frames (I wrote some routines to cycle through frames and execute the "By" expression on the frames). I posted the latter on the selenium forums and have not seen any 'fixes' at this point. For the former, I dug deeper into how XPath works.
so how come the string "my school is" doesn't match? (for startsWith method)
the page I'm testing on no.2 looks like this:
Joined: Jun 30, 2003
For the first one, if you inspect the portion of the statement "driver.findElement(By.id("address")).getText()" what are you getting? You may have some white space or something at the top. Is there another element on the page with id='address' which you could be getting instead?
On the second one, I think you are making the same mistake I did while starting up with Xpath. 'By.xpath("//div[@id='content2']//a"' does not exist. Looking at your example, it is more something like //div/div/ul/font/li/a (I may be missing a few too at a quick glance!) If you want it to find the ''a'' element you'll need to give some instructions to have it go deeper in the chain (you can do some wild carding).
Depending on whose page this is, I will also suggest you look into using an approach like //div[contains(@id,"text")] as opposed to a straight equals that way if the id is augmented or rendered differently on another browser like with spaces it will still work. Also helps if you get into some complex tags you can just specify enough to match what you are looking for.
I used this site as a basis to build an XPathTest of my own to explore XPath syntax deeper. If you have not seen it, review the xpath tutorial at w3schools. I have used this almost exclusively as my reference for what can be done.