Archive

Tag Archives: xml

If your XML has default name space like:
    <COLLADA xmlns=”http://www.collada.org/2005/11/COLLADASchema”></COLLADA&gt;
Then to use DOMXpath you should register this namespace with some prefix like:
    $xpath->registerNameSpace(‘dp’, ‘http://www.collada.org/2005/11/COLLADASchema&#8217;);
here ‘dp’ means default prefix;
Then use this prefix in your XPath query like:
    $nodes = $xpath->query(‘//fp:COLLADA’);

// real example
$DOMDocument = new DOMDocument;
$DOMDocument->strictErrorChecking = false;
//$sXml = ‘<COLLADA xmlns=”http://www.collada.org/2005/11/COLLADASchema”></COLLADA>&#8217;;
if (! $DOMDocument->loadXML($sXml))
    _error(“can’t parse XML”);

$xpath = new DOMXpath($DOMDocument);
$xpath->registerNameSpace(‘dp’, ‘http://www.collada.org/2005/11/COLLADASchema&#8217;);

foreach ($xpath->query(‘//dp:image/dp:init_from’) as $node)
{
    $node->nodeValue = $dir . “/model.jpg”;
}

$sXml = $DOMDocument->saveXML();

Advertisements

<?php

// XML/XSL: Transform one tag into another
// You need to have php_xsl.dll in your php extenstions

function transform($xml, $xsl) {
   $xslt = new XSLTProcessor();
   $xslt->importStylesheet(new SimpleXMLElement($xsl));
   return $xslt->transformToXml(new SimpleXMLElement($xml));
}

$sXml  = ‘<xml><sudhir><image id=”model_jpg” name=”model_jpg”>
  <init_from>models/cersi_ships/model.jpg</init_from>
  </image></sudhir></xml>’;

$sXsl  = ‘<xsl:stylesheet
    xmlns:xsl=”http://www.w3.org/1999/XSL/Transform&#8221; version=”1.0″>
    <xsl:output method=”xml”/>

    <xsl:template match=”image/init_from”>
        <init_from2><xsl:value-of select=”.”/></init_from2>
    </xsl:template>

    <xsl:template match=”* | @*”>
        <xsl:copy><xsl:copy-of select=”@*”/><xsl:apply-templates/></xsl:copy>
    </xsl:template>
   
</xsl:stylesheet>’;

echo transform($sXml, $sXsl);

Last week I finished with desing and implementation of tournaments feature of our social game about army.
Taking just raw idea of the tournament I’ve done both the server side (C#.NET+MSSQL) and the client side (Flash+ActionScript3), communication protocol, designed gameplay workflow and formalized details of UI for artist to make art. As result, there is a nice feature in the game.

One more time I have ability to prove the ability to work very productive as both the client side and the server side developer beyond the opinion of other people who claimed that it’s impossible.

Army_tournament_1Army_tournament_2