Forum Moderators: open
if ( $dom = domxml_open_file( $root."xml/sidebar.xml" ) )
{
$context = xpath_new_context( $dom );
$blocks = xpath_eval( $context, "/sidebar/block[@id=/sidebar/group[@id='$sidebar']/block-ref/@id]" );
$blocks = $blocks->nodeset;
$xml .= "<sidebar>";
while( $block = each( $blocks ) )
{
$block = $block[1];
$context = xpath_new_context( $block );
$xml .= $dom->dump_node( $block );
}
$xml .= "</sidebar>";
}
I'm basically getting a little lost with the xpath reading the blocks tree. Below is a sample of the xml it is reading:
<sidebar>
<block id="catno">
<name>Find HTFR cat number</name>
<catno/>
</block>
<block id="logon">
<logon/> <!-- xsl stuff -->
</block>
<block id="newsite">
<name>htfr site enhancements</name>
<p>Let us know what you think of our new site, or of any bugs you may have found.</p>
<link>Click here to email us</link>
</block>
</sidebar>
Please can someone help me solve this problem or at least enlighten me about the change in xpath.
$dom->load( $root.'xml/sidebar.xml' );
$xpath = new DomXPath($dom);
$blocks = $xpath->query( "/sidebar/block[@id=/sidebar/group[@id='$sidebar']/block-ref/@id]" );
$xml .= "<sidebar>";
foreach( $blocks as $block )
{
$xml .= $dom->saveXML( $block );
}
$xml .= "</sidebar>";
Rather simpler code than php4 but was a bugger to work out!