php-general Digest 23 Aug 2010 20:04:33 -0000 Issue 6907
Topics (messages 307627 through 307629):
Re: xml/cap problems
307627 by: Adam Richardson
Re: google maps API
307628 by: Ken Guest
strtotime()
307629 by: Rick Pasotto
Administrivia:
To subscribe to the digest, e-mail:
[email protected]
To unsubscribe from the digest, e-mail:
[email protected]
To post to the list, e-mail:
[email protected]
----------------------------------------------------------------------
--- Begin Message ---
On Sat, Aug 21, 2010 at 5:53 PM, Tom Shaw <[email protected]> wrote:
> I am trying to decode and encode nws compatible cap xml. An example is at
> the bottom of this post. simplexml_load_file works fine if "cap:" is removed
> before processing. However, if it is not simplexml_load_file does not parse
> the file at all and libxml_get_errors returns no errors.
>
> Any and all help is appreciated.
>
> Tom
>
> <?xml version='1.0' encoding='UTF-8' standalone='yes'?>
> <cap:alert xmlns:cap='http://www.incident.com/cap/1.0'>
> <cap:identifier>NOAA-NWS-ALERTS National
> 2010-08-21T13:26:34-04:00</cap:identifier>
> <cap:sender>[email protected]</cap:sender>
> <cap:sent>2010-08-21T13:26:34-04:00</cap:sent>
> <cap:status>Actual</cap:status>
> <cap:msgType>Alert</cap:msgType>
> <cap:scope>Public</cap:scope>
> <cap:note>
> Current Watches, Warnings and Advisories for the United States Issued by
> the National Weather Service
> </cap:note>
> <cap:references>http://www.weather.gov/alerts/us.html</cap:references>
> <cap:info>
> <cap:category>Met</cap:category>
> <cap:event>na</cap:event>
> <cap:urgency>Unknown</cap:urgency>
> <cap:severity>Unknown</cap:severity>
> <cap:certainty>Unknown</cap:certainty>
> <cap:headline>
> Current Watches, Warnings and Advisories for Alaska Issued by the National
> Weather Service
> </cap:headline>
> <cap:web>http://www.weather.gov/alerts/us.html#ak</cap:web>
> </cap:info>
> ....
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
Hi Tom,
Remember, the namespace is the uri, and the prefix is merely a short-hand:
http://www.w3.org/TR/REC-xml-names/
<http://www.w3.org/TR/REC-xml-names/>When using simple xml objects, you can
directly reference elements by using the namespace:
http://www.sitepoint.com/blogs/2005/10/20/simplexml-and-namespaces/
<http://www.sitepoint.com/blogs/2005/10/20/simplexml-and-namespaces/>However,
my preference is to use XPath capabilities, and I've processed a couple
elements on your example to demonstrate how this works:
$doc = <<<EOD
<test xmlns:cap='http://www.incident.com/cap/1.0'>
<cap:alert>
<cap:identifier>NOAA-NWS-ALERTS National
2010-08-21T13:26:34-04:00</cap:identifier>
<cap:sender>[email protected]</cap:sender>
<cap:sent>2010-08-21T13:26:34-04:00</cap:sent>
<cap:status>Actual</cap:status>
<cap:msgType>Alert</cap:msgType>
<cap:scope>Public</cap:scope>
<cap:note>
Current Watches, Warnings and Advisories for the United States Issued by the
National Weather Service
</cap:note>
<cap:references>http://www.weather.gov/alerts/us.html</cap:references>
<cap:info>
<cap:category>Met</cap:category>
<cap:event>na</cap:event>
<cap:urgency>Unknown</cap:urgency>
<cap:severity>Unknown</cap:severity>
<cap:certainty>Unknown</cap:certainty>
<cap:headline>
Current Watches, Warnings and Advisories for Alaska Issued by the National
Weather Service
</cap:headline>
<cap:web>http://www.weather.gov/alerts/us.html#ak</cap:web>
</cap:info>
</cap:alert>
</test>
EOD;
echo $doc;
$cap = simplexml_load_string($doc);
$cap->registerXPathNamespace('cap', 'http://www.incident.com/cap/1.0');
echo 'Message type:'.current($cap->xpath('//cap:msgType')).'<br />';
echo 'Info category:'.current($cap->xpath('//cap:info/cap:category')).'<br
/>';
Hope this helps,
Adam
--
Nephtali: PHP web framework that functions beautifully
http://nephtaliproject.com
--- End Message ---
--- Begin Message ---
Please consider using the OpenLayers API instead ( http://openlayers.org/
and http://openlayers.org/dev/examples/ for examples) as it will also allow
end-users to choose a OpenStreetMap layer ( http://www.openstreetmap.org/ )
to be displayed which may render more up-to-date details than are available
elsewhere.
Ken
On Mon, Aug 23, 2010 at 3:37 AM, David Mehler <[email protected]> wrote:
> Hello,
> Has anyone worked with the google maps API to put a map on their site?
> If so, please contact me offlist i need to get it going.
> Thanks.
> Dave.
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--
http://blogs.linux.ie/kenguest/
--- End Message ---
--- Begin Message ---
On my home machine running 5.3.2-2 in debian linux the commands:
echo date('Y-m-d',strtotime('first day of this month')).'<br/>';
echo date('Y-m-d',strtotime('last day of next month'));
give the expected results.
I just got setup with a hosting provider running 5.2.13 on BSD and both
give '1969-12-31'.
What could be causing this? The second command is straight from the
manual and the first is clearly implied.
So far everything else seems to work as expected.
--
"Economics is extremely useful as a form of employment for economists."
-- John Kenneth Galbraith
Rick Pasotto [email protected] http://www.niof.net
--- End Message ---