[Chameleon] XMLObject example

Kralidis,Tom [Burlington] Tom.Kralidis at ec.gc.ca
Mon Sep 19 13:46:20 EDT 2005


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/



More information about the Chameleon mailing list