How to output KML and a list at the same time

36 views
Skip to first unread message

mikemcc

unread,
Apr 1, 2010, 12:36:19 PM4/1/10
to KML Developer Support - KML Server Side Scripting
Hello. Can any kind PHP / KML expert please tell me how to output:
- KML file(s) as well as
- echo management information to the screen
while only processing the data once.

I use the:
echo kml[] = '<html tags> etc';
method to create KML files without problems
and:
echo 'report info<br>';
to report what has been created without problems.

But if I try to do both while processing the data only once, GE
complains that the KML has non-KML data when it tries to parse the
file.

I haven't tried this for a couple of months but obviously I can try
again and give more specific example code if necessary to help someone
help me, but I suspect that experienced server-side scripters do this
all the time and might be able to point me in the right direction
without further info. Somehow I have to get data going to 2 different
output "channels" at the same time, I suspect. Many thanks.

nicodemussunrise

unread,
May 23, 2010, 9:46:04 PM5/23/10
to KML Developer Support - KML Server Side Scripting
mikemcc,

It isn't exactly 'to the screen', but I've got a bit of experience
administering web servers, and the preferred way to do it is to echo
management information to what's called STDERR (standard error-- which
should default to the webserver's error log). I'm not a PHP guru, but
if you google 'PHP stderr' you should get a head start.

Another option (if you absolutely must print management information in
the KML) would be to print valid KML even in an error condition. That
is, when your script realizes it can't properly complete the KML
generation operation, it instead prints some basic KML with an error
message (say... in the 'name' tag of the master Document).

Hope that helps.
-ns
--
You received this message because you are subscribed to the Google Groups "KML Server Side Scripting" group.
To post to this group, send email to kml-support-serv...@googlegroups.com.
To unsubscribe from this group, send email to kml-support-server-sid...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/kml-support-server-side-scripting?hl=en.

SlowTarget

unread,
May 24, 2010, 12:50:57 PM5/24/10
to KML Developer Support - KML Server Side Scripting
I just had a look at the way I do this.


1. Rather than using 'echo' whenever you have something to output,
append it to a string instead. Then echo that string or write it to a
file when you've finished processing your data.

and/or

2. Use XML to create your KML file. $dom = new DOMDocument(); etc ..
> To post to this group, send email to [email address].
> To unsubscribe from this group, send email to [email address].

mikemcc

unread,
May 26, 2010, 5:30:53 PM5/26/10
to KML Developer Support - KML Server Side Scripting
Thanks Nico..rise and Slow

I wasn't very clear. I want to open a KML in the 3D viewer with lots
of placemarks on one screen and at the same time list these placemarks
on a 2nd screen with lots more info about each placemark. No errors
involved (I hope). So SlowTarget's approach #1 seems the way to go -
just like building up the lines of KML code before opening it.

Thanks both.

Reply all
Reply to author
Forward
0 new messages