Hi, building a database backend for a Google Map application.
Struggling along in PHP (I'm a java dude) but doing pretty good. The
code below has me confused. Both will create valid files if sent to a
file. Both display perfectly in browser when you access the script
directly. However, only the 2nd one sends readable data back to my
application. The first one generates no elements errors.
Anyone have an idea why this doesn't work:
<?php
$xmlDocument = domxml_new_doc('1.0');
$documentElement = $xmlDocument->create_element('soldiers');
$xmlDocument->append_child($documentElement);
$god = $xmlDocument->create_element('soldier');
$god->append_child($name);
$name = $xmlDocument->create_attribute('rank', 'MSG');
$god->append_child($name);
$name = $xmlDocument->create_attribute('name', 'Joe, G.I.');
$god->append_child($name);
$name = $xmlDocument->create_attribute('street', '2600 North Highlands
Avenue');
$god->append_child($name);
$name = $xmlDocument->create_attribute('city', 'Atlanta');
$god->append_child($name);
$name = $xmlDocument->create_attribute('state', 'DC');
$god->append_child($name);
$name = $xmlDocument->create_attribute('zip', '30101');
$god->append_child($name);
$name = $xmlDocument->create_attribute('lat', '34');
$god->append_child($name);
$name = $xmlDocument->create_attribute('lng', '-84');
$god->append_child($name);
$documentElement->append_child($god);
echo $xmlDocument->dump_mem(true, 'UTF-8');
?>
and this:
<?php
header("content-type:text/xml");
print '<?xml version="1.0" encoding="ISO-8859-1"?>';
print '<soldiers>';
print "<soldier rank=\"MSG\" name=\"Joe, G.I.\" street=\"2600 North
Highlands Avenue\" city=\"Atlanta\" state=\"GA\" zip=\"30101\"
lat=\"34\" lng=\"-84\" />";
print '</soldiers>';
?>
I figured I would go with the first to have better code. But, since I
can't delay any longer had to go with the 2nd. Just curious as to why
it seems to work but doesn't!
Stacy