I cannot seem to figure this bit out. I'm trying to load data from an xml file depending on what the value of a url parameter is. I have an attribute set in my xml, but cannot seem to figure out how to go about this. I've looked at several examples of getting the attribute so I'm not sure where I am wrong since I haven't come across an example using url parameters to determine what data should be fetched. Here is what I have so far.

An example of my `xml` file. There will be more records of `piercing` in this file.

```
<piercings>
 <piercing id="antieyebrow">
  <title>Anti-Eyebrow</title>
  <names>Anti-Eyebrow, Teardrop</names>
  <gauge>16</gauge>
  <healing>6 - 8</healing>
  <risk>Rejection/Migration, Scarring</risk>
  <description>The anti-eyebrow piercing is located on the upper side of the cheek bone right below the orbital socket of the eye. This piercing is most commonly pierced using a 16 gauge curved barbell or custom bent jewelry. This piercing may also be referred to as a teardrop piercing.</description>
  <aftercare>It is recommended with this piercing to clean twice a day using saline solution or antibacterial soap. Do not overclean. Irritation from overcleaning can result in migration of the piercing.
</aftercare>
  <avoid>Using rubbing alchohol as a cleaner. Changing the jewelry for atleast 3 weeks although recommended to wait until the piercing is fully healed. Pools/hot tubs especially those with chemical cleaners in them. Swimming holes, creeks, rivers, etc. due to bacterial exposure risk.</avoid>
  <img>http://example.com/img/display/stock/antieyebrow_default.jpg</img>
  <additionalimgs>
   <additionalimg>http://example.com/img/thumb/stock/antieyebrow_1.jpg</additionalimg>
   <additionalimg>http://example.com/img/thumb/stock/antieyebrow_2.jpg</additionalimg>
   <additionalimg>http://example.com/img/thumb/stock/antieyebrow_3.jpg</additionalimg>
  </additionalimgs>
 </piercing>
</piercings>

```

So for this one I am trying to pull all of the data for the `piercing` with the attribute of `id="antieyebrow"`. Here is what I tried to retrieve that.

```
 if (file_exists($_SERVER['DOCUMENT_ROOT'].'/info/piercing/piercings.xml')) {   
  $piercingxml = simplexml_load_file($_SERVER['DOCUMENT_ROOT'].'/info/piercing/piercings.xml');
  $location = $_GET['location'];
  $piercingid = $piercingxml['id'];                  
 }
 else {
  $piercingxml = simplexml_load_file($_SERVER['DOCUMENT_ROOT'].'/info/piercing/default.xml');
  $location = "default";
 }

```

And finally to display the data onto the page:

```
echo $piercingxml->$piercingid[$location]->title;

```

Any help as to where I went wrong would be greatly appreciated.