This is driving me crazy. I could have copied and pasted the 2 values I need and been done with this 30 minutes ago, but instead I'm trying to do it "right".

There is only ONE "username" in the entire file. How do I get it? I tried using xpath ( `$username=$xml->xpath('default_setup/connection/username');` ) and I tried chaining the nodes up to it ( $username=$xml->{...full path here...}->default\_setup->connection->username;` ).

When I `print_r($xml)`, I can see all the nodes I want and their values. When I `print_r($username)` I get nothing.

```
<?php
$xml = simplexml_load_file('database.xml',NULL,LIBXML_NOCDATA); // connection details are inside of CDATA

$username=$xml->xpath('default_setup/connection/username'); ?>
<p>Username: <?= (string)$username ?></p><?php // outputs "Array"

<?php
foreach($xml as $element) {
        echo $element . '<br />'; // outputs '<br />' 2 times.
}
?>
<pre>
Username:
<?php print_r($username) ?><?php // nothing ?>
xml:
<?php print_r($xml) ?><?php // full set of all nodes with everything I need just out of reach ?>
</pre>

```

Here is the sample xml. (It is actually the Magento "app/etc/local.xml" file)

```
<default_setup>
    <connection>
        <host><![CDATA[localhost]]></host>
        <username><![CDATA[secret_username]]></username>
        <password><![CDATA[secret_password]]></password>
        <dbname><![CDATA[testing_database]]></dbname>
        <initStatements><![CDATA[SET NAMES utf8]]></initStatements>
        <model><![CDATA[mysql4]]></model>
        <type><![CDATA[pdo_mysql]]></type>
        <pdoType><![CDATA[]]></pdoType>
        <active>1</active>
    </connection>
</default_setup>

```