[Chameleon] XMLObject example

Paul Spencer pspencer at dmsolutions.ca
Mon Sep 19 20:47:52 EDT 2005


Tom,

here's an example script that would extract the minscale/maxscale  
from a context document as an example of using XMLObject.php

Cheers

Paul
-------------- next part --------------
A non-text attachment was scrubbed...
Name: context.php
Type: text/php
Size: 749 bytes
Desc: not available
Url : http://lists.maptools.org/pipermail/chameleon/attachments/20050919/cd526b50/context.bin
-------------- next part --------------

On 19-Sep-05, at 1:46 PM, Kralidis,Tom [Burlington] wrote:

>
> Hi,
>
> We are trying to add some extra functionality to our cwc2 instance to
> handle the extra goodies which are part of the WMC 1.1.0 specification
> (specifically scale denominations).
>
> In htdocs/common/xml_utils/XMLObject.php, we tried replicating the
> example given in the class, i.e.:
>
>  * Sample XML document:
>  * <Employees version="1.0">
>  *   <Employee Id="1">
>  *     <Name>John</Name>
>  *     <Salary Type="Annualy">20K</Salary>
>  *   </Employee>
>  *   <Employee Id="2">
>  *     <Name>Ren</Name>
>  *     <Salary Type="Weekly">2K</Salary>
>  *   </Employee>
>  * </MyRoot>
>  *
>  * Sample PHP code:
>  *
>  * $oXMLObj = new XMLObject( $szXMLDoc );
>  *
>  * $oEmployees = $oXMLObj[0];
>  *
>  * if ($oEmployees->version >= "1.0")
>  * {
>  *   foreach($Employees->children as $oEmployee)
>  *   {
>  *     echo $oEmployee->Id." ";
>  *     echo "Name: ".$oEmployee->getNextChild("Name")->value."\n";
>  *     $oSalary = $oEmployee->getNextChild("Salary");
>  *     echo "Paid: ".$oSalary->value."(";
>  *     echo $oSalary->Type.")";
>  *   }
>  * }
>  * else
>  *   echo "Wrong document version";
>  *
>  */
>
> ...but run into the following problem:
>
> Fatal error: Cannot use object of type XMLObject as array in
> /home/tkralidi/dev-php/mm.php on line 7
>
> Our basic plan of attack will be to:
>
> - Loop over WMC once again after cwc2.php does so with an XML parser
> - fetch Layers with scale denominations
> - apply scale settings to layer object in mapscript
>
> Comments and advice would be appreciated.  We are trying XMLObject.php
> because we are having a tough time using some of the other PHP XML
> tools.
>
> Thanks
>
> ..Tom
>
> =========================
> Tom Kralidis
> Senior Systems Scientist
> Environment Canada
> Tel: +01-905-336-4409
> http://www.ec.gc.ca/
>
> _______________________________________________
> Chameleon mailing list
> Chameleon at lists.maptools.org
> http://lists.maptools.org/mailman/listinfo/chameleon
>

+-----------------------------------------------------------------+
|Paul Spencer                           pspencer at dmsolutions.ca   |
+-----------------------------------------------------------------+
|Applications & Software Development                              |
|DM Solutions Group Inc                 http://www.dmsolutions.ca/|
+-----------------------------------------------------------------+






More information about the Chameleon mailing list