Hi,
I’d be really grateful if someone could help get me started with parsing xml using simplexml_load_file.
Here’s the xml in extracts:
[xml]
<?xml version=“1.0” encoding=“UTF-8” ?>
-
<getHistogramsResponse>
-
<aspectHistogramContainer>
<domainName>Video_Games_Games</domainName>
<domainDisplayName>Video Games</domainDisplayName> -
<aspect name=“Platform”>
-
<valueHistogram valueName=“Sony PlayStation”>
<count>66710</count>
</valueHistogram> -
<valueHistogram valueName=“PC”>
<count>65410</count>
</valueHistogram> -
<valueHistogram valueName=“Sony PlayStation 2”>
<count>56494</count>
</valueHistogram>
…
</aspect> -
<aspect name=“Genre”>
-
<valueHistogram valueName=“Action, Adventure”>
<count>142497</count>
</valueHistogram> -
<valueHistogram valueName=“Arcade”>
<count>5034</count>
</valueHistogram>
</aspect>
… -
<aspect name=“Rating”>
-
<valueHistogram valueName=“EC - Early Childhood”>
<count>1098</count>
</valueHistogram> -
<valueHistogram valueName=“E - Everyone”>
<count>232873</count>
</valueHistogram>
…
</aspect>
</aspectHistogramContainer> -
<conditionHistogramContainer>
-
<conditionHistogram>
<conditionId>6000</conditionId>
<conditionDisplayName>Acceptable</conditionDisplayName>
</condition>
<count>73729</count>
</conditionHistogram> -
<conditionHistogram>
-
<condition>
<conditionId>5000</conditionId>
<conditionDisplayName>Good</conditionDisplayName>
</condition>
<count>104059</count>
</conditionHistogram>
…
</conditionHistogramContainer>
</getHistogramsResponse>
[/xml]
I know I need to drill down through the xml nodes but I am struggling with the correct syntax for filtering using both attributes and elements.
For example, how would I target each of the platform options then move on to each of the condition options.
All advice very much appreciated.