Tag Archives: xml

If your XML has default name space like:
    <COLLADA xmlns=””></COLLADA&gt;
Then to use DOMXpath you should register this namespace with some prefix like:
    $xpath->registerNameSpace(‘dp’, ‘;);
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=””></COLLADA>&#8217;;
if (! $DOMDocument->loadXML($sXml))
    _error(“can’t parse XML”);

$xpath = new DOMXpath($DOMDocument);
$xpath->registerNameSpace(‘dp’, ‘;);

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

$sXml = $DOMDocument->saveXML();


// 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”>

$sXsl  = ‘<xsl:stylesheet
    xmlns:xsl=”; version=”1.0″>
    <xsl:output method=”xml”/>

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

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

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.