Hello…
I have been trying to fix a problem for the last 2 days…but have been unsuccessful.
Here is what I need.
I have an XML file:sample content of myxmlfile.xml
<feedstart>
<mainnode id="1A" offid="X13">
<data>
<Sub1></Sub1>
<Sub2></Sub2>
<Sub3>
<SubSub1></SubSub1>
<SubSub2></SubSub2>
<SubSub3></SubSub3>
<SubSub4></SubSub4>
</Sub3>
</data>
<otherinfo></otherinfo>
<userimages total="5">
<image url="theurl.com/node1image1.jpg" alttxt="imagealt" value="1" />
<image url="theurl.com/node1image2.jpg" alttxt="imagealt" value="2" />
<image url="theurl.com/node1image3.jpg" alttxt="imagealt" value="3" />
<image url="theurl.com/node1image4.jpg" alttxt="imagealt" value="4" />
<image url="theurl.com/node1image5.jpg" alttxt="imagealt" value="5" />
</userimages>
<generalinfo></generalinfo>
</mainnode>
<mainnode id="2A" offid="X14">
<data>
<Sub1></Sub1>
<Sub2></Sub2>
<Sub3>
<SubSub1></SubSub1>
<SubSub2></SubSub2>
<SubSub3></SubSub3>
<SubSub4></SubSub4>
</Sub3>
</data>
<otherinfo></otherinfo>
<userimages total="3">
<image url="theurl.com/node2image1.jpg" alttxt="imagealt" value="1" />
<image url="theurl.com/node2image2.jpg" alttxt="imagealt" value="3" />
<image url="theurl.com/node2image3.jpg" alttxt="imagealt" value="3" />
</userimages>
<generalinfo></generalinfo>
</mainnode>
<mainnode id="3A" offid="X15">
<data>
<Sub1></Sub1>
<Sub2></Sub2>
<Sub3>
<SubSub1></SubSub1>
<SubSub2></SubSub2>
<SubSub3></SubSub3>
<SubSub4></SubSub4>
</Sub3>
</data>
<otherinfo></otherinfo>
<userimages total="4">
<image url="theurl.com/node3image1.jpg" alttxt="imagealt" value="1" />
<image url="theurl.com/node3image2.jpg" alttxt="imagealt" value="2" />
<image url="theurl.com/node3image3.jpg" alttxt="imagealt" value="3" />
<image url="theurl.com/node3image4.jpg" alttxt="imagealt" value="4" />
</userimages>
<generalinfo></generalinfo>
</mainnode>
</feedstart>
My PHP file is:
<?
$objDOM = new DOMDocument();
$objDOM->load("myxmlfile.xml");
$params = $objDOM->getElementsByTagName("image");
foreach( $params as $picture )
{
$theurl = $picture -> getAttribute('url');
echo "$theurl ";
}
?>
Now with my current code, the url is printed continuously without any breaks.
like this
node1image1.jpg node1image2.jpg node1image3.jpg node1image4.jpg node1image5.jpg node2image1.jpg node2image2.jpg node2image3.jpg node3image1.jpg node3image2.jpgnode3image3.jpgnode3image4.jpg
What I really want is something like this
node1image1.jpg node1image2.jpg node1image3.jpg node1image4.jpg node1image5.jpg
node2image1.jpg node2image2.jpg node2image3.jpg
node3image1.jpg node3image2.jpgnode3image3.jpgnode3image4.jpg
I am basically not able to set a break when that particular node ends.
Basically what would be needed is get the count either via XML or if you see my XML the count is there itself
<userimages total="5">
<userimages total="3">
<userimages total="4">
from which if someone could modify my script to incorporate the count and break
Any ideas?