I am trying to search a XML document I created but I can't seem to get it to work properly. Here is my XML document...
<?xml version="1.0" encoding="UTF-8"?>
<states>
<repstate location="AL">
<compName>Test Company</compName>
<name>Chris Brown</name>
<address>123 Main St</address>
<city>Anytown</city>
<state>CT</state>
<phone>203-123-4567</phone>
<fax>203-456-7890</fax>
<email>info@email.com</email>
<website>www.testing.com</website>
<serviceArea>All of Alabama</serviceArea>
</repstate>
<repstate location="AK">
<compName>Test Company</compName>
<name>Chris Brown</name>
<address>123 Main St</address>
<city>Anytown</city>
<state>CT</state>
<phone>203-123-4567</phone>
<fax>203-456-7890</fax>
<email>info@email.com</email>
<website>www.testing.com</website>
<serviceArea>All of Alabama</serviceArea>
</repstate>
</states>
and here is the code snippet i'm trying to get to work...
<?php
$xml = simplexml_load_file('../../usa.xml');
$found = $xml->xpath("//@location='AK'");
echo $found->state;
?>
It doesn't seem to be working properly.
I'm trying to load the information in that node. So all the compName, name, address, city, state, phone, fax, email, website and serviceArea. I thought it would be easy to just get "state" working but nothing seems to output. What am I doing wrong?