Xml isn’t a text stream, it is a nodelist. Rather than echoing, try creating an xml document using the appropriate bits of php then sending that to the browser.
I have looked into some examples but my problem is they all directly turn the table structure of the database into the XML file but I need to just cherry pick the required columns - that’s why I was trying to use the echo.
Any pointers on doing this? I’d really appreciate it.
The
will make it appear on a new line. Use \r for Unix-based systems. The \ acts as a tab, which will help keep your code organized. As always, make sure nothing is outputted to the screen before you try to execute header(), otherwise you will get an error.
I have no problem querying the database but I have no idea how to output the result as a formatted XML file that can then be used / pulled into a flash file.
This is the ‘format’ I have to reproduce using data from my database.
<?xml version="1.0" encoding="utf-8"?>
<data>
<settings
stageWidth=""
stageHeight=""
stageBgColor="ffffff"
stageTransperent=""
/>
<!-- LOCATION 1 -->
<location x="" y="" landmarkImage="land1" landmarkImageResizeOnZoom="yes" link="http://flashden.net/user/FMedia" target="_blank" shadow="no">
<popup image="map_asset/image1.jpg">
<popupTitle><![CDATA[Interactive Map]]></popupTitle>
<popupDescription><![CDATA[The main map can be loaded dynamically using xml or created inside the flash itself.]]></popupDescription></popup></location>
</data>
The location will obviously be repeated per location - I was using
No, this is wrong. Older Mac systems used \r, I have no idea what they use now - they might be in line with unix now. Unix systems use
, windows uses \r
.
However, it seems echo does format the XML in a ‘good enough’ format.
The reason my feed was failing in flash was a single ‘white’ space before the XML doc tag. Making sure the echo writing this was placed right at the beginning before any other script fixed the whole issue.
Perhaps yes. On the other hand, you have some urls and other stuff which could easily grow query strings. And better to use a proper library and never have to worry about this stuff rather than treat Xml as a string. Yeah, I’m on the lunatic fringe.