php simplexmlelement get first element in one line
        Posted  
        
            by Senica Gonzalez
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Senica Gonzalez
        
        
        
        Published on 2010-05-12T01:35:27Z
        Indexed on 
            2010/05/12
            1:44 UTC
        
        
        Read the original article
        Hit count: 344
        
php
|simplexmlelement
Just trying to figure a shorter way to do this:
I'm using simpleXMLElement to parse an xml file and it's aggravating to have to call two lines to process an array when I know what node I want.
Current code:
$xml = new SimpleXMLElement($data);
$r = $xml->xpath('///givexNumber');
$result["cardNum"] = $r[0];
What I would like to do would be something like I can do with DomX
$result["cardNum"] = $xml->xpath('///givexNumber')->item(0)->nodeValue;
Any ideas?
I didn't really see that simplexmlelement can do this, but thought someone might know a trick or two.
© Stack Overflow or respective owner