如何在php中访问xml中的节点

I have the following xml schema but i don't know how to access this in php. please help me in accessing it.

here is the samples structure

<PropertyDetails>
   <ListingID>listingid</ListingID>
   <AgentDetails ID="13245">
      <Name>Agent Name One</Name>
      <Phones>
         <Phone ContactType="Business" PhoneType="Telephone">123-45678</Phone>

      </Phones>
      <Office ID="65">
         <Name>BROKER</Name>
         <Address>
            <StreetAddress>17 Z STREET</StreetAddress>
            <AddressLine1>1 T STREET</AddressLine1>
            <City>BE</City>
            <PostalCode>142001</PostalCode>
         </Address>
         <Phones>
            <Phone ContactType="Business" PhoneType="Telephone">123-45678</Phone>
            <Phone ContactType="Business" PhoneType="Fax">123-45678</Phone>
         </Phones>
         <Websites>
            <Website ContactType="Business" WebsiteType="Website">www</Website>
         </Websites>
      </Office>
      <Designations>
         <Designation>BRD</Designation>
      </Designations>
   </AgentDetails>
   <AgentDetails ID="163">
      <Name>Agent Name Two</Name>
      <Phones>
         <Phone ContactType="Business" PhoneType="Telephone">(103) 321-134</Phone>
         <Phone ContactType="Business" PhoneType="Fax">(603) 132-1222</Phone>
      </Phones>
      <Office ID="27">
         <Name>HRC, BR</Name>
         <Address>
            <StreetAddress>1 N STREET</StreetAddress>
            <AddressLine1>7 P STREET</AddressLine1>
            <City>BE</City>
            <PostalCode>142001</PostalCode>
         </Address>
         <Phones>
            <Phone ContactType="Business" PhoneType="Telephone">123 6578</Phone>
            <Phone ContactType="Business" PhoneType="Fax">321-134</Phone>
         </Phones>
      </Office>
      <Designations>
         <Designation>BR</Designation>
      </Designations>
   </AgentDetails>
   </PropertyDetails>

in php

$xml = simplexml_load_file("seven.xml") or die("Error: Cannot create object");
echo 'Agent Details'.$xml['AgentDetails']->Name;

at above line it gives me error Notice: Trying to get property of non-object in C:\xampp\htdocs\cr\services\create.php on line 3

I am new in accessing xml in php. please help.

Just simple access it as a normal object like this:

echo 'Agent Details: '.$xml->AgentDetails[0]->Name;

Output:

Agent Details: Agent Name One


If you want to see the structure of your variable (object) just do this and you will see how to access it:

print_r($xml);

Also for more information about simplexml_load_file() see the manual: http://php.net/manual/en/function.simplexml-load-file.php