Skip to content
Advertisement

PHP extract data from xml nodes with same name

I am trying to extract values from a review xml file with deep node structure. I need to extract data from the parent node “reviews->reviews” AND from the child node “rating” WHERE ‘questionGroup’ = “DEFAULT_OPINION”. I tried several code variants, but can’t find a solution to get both values after searching for quite a while.

This is a part of the xml file:

JavaScript

This is my current code:

JavaScript

I also tried:

JavaScript

In the first code I get the results with name and city and the rating from the first node. In the second code I get the review I would like to display as ratingvalue, but not the parentnode data. How do I get this review data together with the results of the first code?

Advertisement

Answer

You have to loop through your review content and add condition for getting review for particular question group type

JavaScript
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement