| E. Porting MiniXML to the DOMIT Library |
|
E. Porting MiniXML to the DOMIT Library From 4.5.1 the XML parser has been upgraded to DOMIT! (http://www.engageinteractive.com/domit/). This has been done to solve a conflict in the MiniXML library with PHP Version 4.2.2. DOMIT is also a far more mature library and development is ongoing where other libraries seem to have stagnated. As a result, the MiniXML libraries have been deleted from the source distribution. Any component or module that relied on the MiniXML libraries has two choices. Either include your own MiniXML source file, or upgrade to using DOMIT! The later is obviously recommended. It's quite easy. It just takes a few steps to convert a few functions over. Just following the following steps. Finding elements by path Replace: $e = &$xml->getElementByPath( 'mosinstall/name' ); With: $e = &$xml->getElementsByPath( 'name', 1 ); Getting the contents of a text node Replace: $e->getValue(); With: $e->getText(); Getting the child nodes array Replace: $e->getAllChildren( ); With: $e->childNodes; Loading the XML file Replace the following type of block $xmlDoc = new MiniXMLDoc( $dirName . $xmlfile ); $xmlDoc->fromFile( $dirName . $xmlfile ); $element = &$xmlDoc->getElementByPath( 'mosinstall' ); mosDebugVar( $element ); if ( is_null( $element ) ) { continue; } if ( $element->attribute( "type" ) != "mosbot") { continue; } With the following type of code block // Read the file to see if it's a valid MOSBot XML file $xmlDoc =& new DOMIT_Lite_Document(); $xmlDoc->resolveErrors( true ); if (!$xmlDoc->loadXML( $dirName . $xmlfile, false, true )) { continue; } $element = &$xmlDoc->documentElement; if ($element->getTagName() != 'mosinstall') { continue; } if ($element->getAttribute( "type" ) != "mosbot") { continue; } Getting the root node Replace: $element = &$xmlDoc->getElementByPath( 'mosinstall' ); With: $element = &$xmlDoc->documentElement; |
|
| Last Updated ( Wednesday, 14 September 2005 ) |