Possible Duplicate:
A simple program to CRUD node and node values of xml file
How would I get a specific Attribute out of this XML feed?
Example – I have been using a line similar to this to get other XML details but I am unsure how I could change it to get a specific Attribute.
$mainPropertyDetails = $mainPropertyUrl->Attributes->attribute;
Attributes:
<Attributes>
<Attribute>
<Name>bedrooms</Name>
<DisplayName>Bedrooms</DisplayName>
<Value>4 bedrooms</Value>
</Attribute>
<Attribute>
<Name>bathrooms</Name>
<DisplayName>Bathrooms</DisplayName>
<Value>2 bathrooms</Value>
</Attribute>
<Attribute>
<Name>property_type</Name>
<DisplayName>Property type</DisplayName>
<Value>House</Value>
</Attribute>
SimpleXMLimplements these nodes as an array. If you were tovar_dump()this, you would see something like:It is therefore just a matter of accessing specific ones by their array index:
Get the Attribute node based on a child’s value:
Using
xpath()you can query for the parentAttributenode based on a child’s text value: