将xml元素与变量php进行比较

I'm trying to compare an element in XML with a variable using simpleXML, but I can't get it right. This is what i have so far:

PHP

$xml = simplexml_load_file('0.xml');

    if((string)$xml->stickers->sticker->id == $id) {  //<-- THIS LINE
        //code to be executed
    }

XML

<stickers>
    <sticker>
        <id>1</id>
        <content>StickerContent</content>
    </sticker>
</stickers>

This leaves me with the Notice:Trying to get property of non-object on the line i marked and i don't know how to fix it.

var_dump($xml)

object(SimpleXMLElement)#1 (1) {
  ["sticker"]=>
  array(2) {
    [0]=>
    object(SimpleXMLElement)#2 (5) {
      ["id"]=>
      string(1) "1"
      ["content"]=>
      string(1) "p"
    }
  }
}

It should be like this:

if ((string) $xml->sticker->id == $id)

Though if you have multiple sticker elements it would be:

if ((string) $xml->sticker[0]->id == $id)