Answer the question
In order to leave comments, you need to log in
Problem with loops when parsing xml, what am I doing wrong?
I have an xml construct
< ?xml version="1.0" encoding="utf-8" ?>
< product prodID="28">
< pictures>
< picture>1< /picture>
< picture>2< /picture>
< picture >3< /picture>
</pictures>
< /product>
< product prodID="53">
< pictures>
< picture>1< /picture>
< picture>2< /picture>
< /pictures>
</product>
Thought parse it like this, but it doesn't come out
<?php
$xml = simplexml_load_file('1.xml');
foreach ($xml->product as $product) {
foreach ($xml->
product->pictures as $pictures) { echo $product[prodID];
echo $pictures->picture;
}
}
?>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question