I've been looking at the other questions posted here on this subject but they all seem to have in common a "symetric" xml file.
I start by calling:
$xml_testimonials=simplexml_load_file("bck/testimonials.xml");
I cant iterate this file:
<?xml version="1.0" encoding="utf-8"?>
<testimonials>
<description><![CDATA[
<p>Give us your feeback!</p>
]]></description>
<testimonials_collection>
<testimonial>
<testimonial_name>
Dummy Name
</testimonial_name>
<testimonial_content>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed nec libero venenatis, posuere massa vitae, volutpat massa. Maecenas placerat ac metus ut pulvinar.
</testimonial_content>
</testimonial>
<testimonial>
<testimonial_name>
Dummy Name
</testimonial_name>
<testimonial_content>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed nec libero venenatis, posuere massa vitae, volutpat massa. Maecenas placerat ac metus ut pulvinar.
</testimonial_content>
</testimonial>
<testimonial>
<testimonial_name>
Dummy Name
</testimonial_name>
<testimonial_content>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed nec libero venenatis, posuere massa vitae, volutpat massa. Maecenas placerat ac metus ut pulvinar.
</testimonial_content>
</testimonial>
</testimonials_collection>
</testimonials>
Im trying to use:
foreach($xml_testimonials->testimonials->testimonials_collection as $testimonial) {
print $testimonial->testimonial->testimonial_name;
}
and Im getting
Warning: Invalid argument supplied for foreach()
Also is there anyway that I can avoid using and retain the html tags?