I wonder whether someone may be able to help me please.
I am using the code below to extract a 'Name' and 'National Grid Reference' from an xml file.
Code:
<?
$objDOM = new DOMDocument();
$objDOM->load("scheduledmonuments.xml");
$Details = $objDOM->getElementsByTagName("Details");
foreach( $Details as $value )
{
$Name = $value->getElementsByTagName("Name");
$name = $Name->item(0)->nodeValue;
$NGR = $value->getElementsByTagName("NGR");
$ngr = $NGR->item(0)->nodeValue;
echo "$name :: $ngr <br>";
}
?>
What I would like to be able to do is to is to carry forward the 'Name' but also convert the 'NGR' to a Latitude and Longitude co-ordinate.
I have the conversion code written as a Javascript function (originally posted on nearby.org.uk), see below.
Code:
function converttolatlng() {
var gr = document.getElementById('osgridref').value;
var osgb = new GT_OSGB();
if (osgb.parseGridRef(gr)) {
var wgs84 = osgb.getWGS84();
document.getElementById('osgb36lat').value = wgs84.latitude;
document.getElementById('osgb36lon').value = wgs84.longitude;
}
else {
document.getElementById('osgb36lat').value = "n/a";
document.getElementById('osgb36lon').value = "n/a";
}
}
At the moment the code takes and places the information into text boxes on a form.
But what I would like to do is to carry forward the 'Name' and convert the 'NGR' values from the PHP file rather than text boxes, posting the results on screen, but I'm not sure how, or whether it can be done.
Could someone perhaps take a look at this please and let me know what I need to do to get this to work.
Many thanks