XML Issues

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
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:

$xmlDocument = domxml_new_doc('1.0');
$documentElement = $xmlDocument->create_element('soldiers');
$god = $xmlDocument->create_element('soldier');
$name = $xmlDocument->create_attribute('rank', 'MSG');
$name = $xmlDocument->create_attribute('name', 'Joe, G.I.');
$name = $xmlDocument->create_attribute('street', '2600 North Highlands
$name = $xmlDocument->create_attribute('city', 'Atlanta');
$name = $xmlDocument->create_attribute('state', 'DC');
$name = $xmlDocument->create_attribute('zip', '30101');
$name = $xmlDocument->create_attribute('lat', '34');
$name = $xmlDocument->create_attribute('lng', '-84');
echo $xmlDocument->dump_mem(true, 'UTF-8');

and this:

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!


Re: XML Issues


 header("content-type:text/xml"­); <-----Forgot this all important

Site Timeline