# Simplexml weirdness

**URL:** <https://forum.kirupa.com/t/simplexml-weirdness/188448>\
**Category:** Uncategorized\
**Created:** [May 8, 2006, 2:48am UTC](https://forum.kirupa.com/t/simplexml-weirdness/188448 "2006-05-08T02:48:28Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![ironikart](https://avatars.discourse-cdn.com/v4/letter/i/7feea3/32.png) [@ironikart](https://forum.kirupa.com/u/ironikart)\
**Post date:** [May 8, 2006, 2:48am UTC](https://forum.kirupa.com/t/simplexml-weirdness/188448/1 "2006-05-08T02:48:28Z")

</div>

From every example I’ve seen, this works properly, but can’t figure out why I cannot get it work! Driving me nuts:

Sample XML

```auto

<?xml version="1.0"?>
<database>
	<tables>
		<table name="#_users">
			<columns>
				<column type="INT(8)" name="id">
					<null>0</null>
					<default></default>
					<primary>1</primary>
					<extra>AUTO_INCREMENT</extra>
				</column>
				<column type="VARCHAR(100)" name="username">
					<null>0</null>
					<index>1</index>
				</column>
			</columns>
			<desc>The users table</desc>
		</table>	
	</tables>
</database>

```

Sample code:

```php

<?php
$xml = simplexml_load_file( $file );
    	
if ( ! empty( $xml ) && $xml instanceof SimpleXMLElement ) {
    	
  	foreach ( $xml->tables as $table ) {
    	
    		print_r ( $table ); // Yep, XML is there!

    		echo $table['name']; // Outputs nothing! WHY?

  	}
}
?>

```

The xml loads as a SimpleXMLElement, I can see all the attributes in there, why the hell can’t I access them? What am I doing wrong?
