Hey PHP gurus...

I have a string with an XML file output stored to it. I need to parse that string and extract data to output into a CSV file. I was able to figure out how to accomplish this for the unique data items in the XML file, but not for the multiple products in the stream. There are multiple line items for each product so I have to loop through that some how, but I'm not clear on how.

This is the XML file:
<address1>123 Shipping Street</address1>
<address2 nil="true"></address2>
<company nil="true"></company>
<country>Shippington Emirates</country>
<name>Steve Shipper</name>
<line-items type="array">
<grams type="integer">5000</grams>
<price type="decimal">199.99</price>
<quantity type="integer">1</quantity>
<variant-id type="integer" nil="true"></variant-id>
<vendor nil="true"></vendor>
<grams type="integer">500</grams>
<price type="decimal">29.95</price>
<quantity type="integer">1</quantity>
<title>Wire Cutter</title>
<variant-id type="integer" nil="true"></variant-id>
<vendor nil="true"></vendor>
<name>Wire Cutter</name>
<price type="decimal">10.00</price>
<title>Generic Shipping</title>

This the PHP that is working so far...
$cr = "\n";
$xml = new SimpleXMLElement($xmlString);

$email = trim($xml->email);
$address1 = trim($xml->{'shipping-address'}->address1);
$address2 = trim($xml->{'shipping-address'}->address2);
$city = trim($xml->{'shipping-address'}->city);
$company = trim($xml->{'shipping-address'}->company);
$country = trim($xml->{'shipping-address'}->country);
$name = trim($xml->{'shipping-address'}->name);
$phone = trim($xml->{'shipping-address'}->phone);
$state = trim($xml->{'shipping-address'}->province);
$zip = trim($xml->{'shipping-address'}->zip);

$data = $name.",".$email.",".$phone.",".$address1.",".$address2.",".$city.",".$company.",".$country.",".$sta te.",".$zip.",".$cr;

Ideas about how to create a loop to assign all the line items and add it to the data variable??

Thanks so much!!