User:Tegnosis/Family History Center Map

The Family History Center Map is used to lookup the URL of a Family History Center from a UnitNbr and uses the FsApiExtension although it's not really an extension, it just lives in the extension directory and is called directly. For example if you had the UnitNbr  and wanted to find the URL, you would use the following:
 * https://www.familysearch.org/en/wiki/extensions/FsApi/FsApiExtension.php?action=unitNbrToFhcWikiPage&unitNbr=1002457

Which would return:

Alternatively, you could get the XML or JSON of the entire page using:
 * https://www.familysearch.org/en/wiki/api.php?format=xml&action=query&pageids=137044&prop=revisions&rvprop=content
 * https://www.familysearch.org/en/wiki/api.php?format=json&action=query&pageids=137044&prop=revisions&rvprop=content

Issue
Sometimes the lookup fails, this seems to happen sometimes when there is an ampersand (&) in the name, for example trying to lookup  using:
 * https://www.familysearch.org/en/wiki/extensions/FsApi/FsApiExtension.php?action=unitNbrToFhcWikiPage&unitNbr=1020455

Returns:  This page isn’t working www.familysearch.org is currently unable to handle this request. HTTP ERROR 500

I added the following to the end as a test where #1 is the same link without any special characters (OK) and the next 3 test each character where only the one (#3) with the ampersand fails. Curiously, #5 fails (as does #6-#8), but #5 is identical to 3337731 above in the list and there are a few others earlier on that have an ampersand and work (1334174, 3359662, 3372200, 406244). The first that fails seems to be 1020455.

Resolution
The issue was the SimpleXMLElement function couldn't handle ampersands (&) so htmlspecialchars was used to replace the ampersand (&) with it's HTML equivalent.