Alter add_permalink to use API. XML is bad, says ChrisK.