Sebastian Bergmann wrote:
> <?php
> $document = new DOMDocument;
> $document->loadXML( '<?xml version="1.0" encoding="UTF-8"?>
> <workflow name="StartSetUnsetEnd" version="1">
>   <node id="1" type="Start">
>     <outNode id="2"/>
>   </node>
>   <node id="2" type="VariableSet">
>     <variable name="x">
>       <integer>1</integer>
>     </variable>
>     <outNode id="3"/>
>   </node>
>   <node id="3" type="VariableUnset">
>     <variable name="x"/>
>     <outNode id="4"/>
>   </node>
>   <node id="4" type="End"/>
> </workflow>' );
> 
> foreach ( $document->getElementsByTagName( 'node' ) as $node )
> {
>     $type = $node->getAttribute( 'type' );
> 
>     if ( $type == 'VariableSet' )
>     {
>         foreach ( $node->getElementsByTagName( 'variable' ) as $variable )
>         {
>             // $variable->getAttribute( 'name' ) returns 'x' as expected.
> 
>             // I want to access the <integer> child node of the <variable>
>             // node at this point but all I see is a DOMText object that
>             // contains whitespace and $variable->nodeValue contains 1
>             // which is the value of the <integer> element.
>         }
>     }
> }
> 
> 

I am not sure what you need, but I think these would work (both return 
"1" without any whitespace):
$variable->childNodes->item( 1 )->nodeValue
$variable->getElementsByTagName( 'integer' )->item( 0 )->nodeValue

Probably there are easier ways to do it.

-- 
Alexandru Stanoi
eZ Components System Developer
eZ Systems | http://ez.no
-- 
Components mailing list
[email protected]
http://lists.ez.no/mailman/listinfo/components

Reply via email to