Hi,

Revisiting this exercise with the hopes of completing a tutorial, the desired output is generated, but running into problems placing the proper standards table elements, <thead><tbody> etc. Would you or someone assist with adding the needed elements required for passing validation with the table?

<http://bushidodeep.com/exercises/xmlphp/groceries/groceries.xml>

<?php
//set the XML fike name as a php string
$myGroceryList="groceries.xml";
//load the XML file
[EMAIL PROTECTED]($myGroceryList) or die ("no file loaded");
//assign the listName element to a string
$nameOfMyShoppingList = $xml->listName;
echo "<h1>List: " . $nameOfMyShoppingList . "</h1>";
/*create a loop that will take each foodGroup element,
display its name, and then list each of the items’ names and quantities.*/
foreach ($xml->foodGroup as $foodGroup){
echo "<h2>Food group name is " . $foodGroup->groupName . "</h2>";
foreach ($foodGroup->item as $foodItem){
echo '<table border="1" cellpadding="0" cellspacing="0">
<thead>
<tr>
<td>Item:</td><td>' . $foodItem->name . '</td>
</tr>
<tr>
<td>Quantity:</td><td>' . $foodItem->howMuch . '</td>
</tr>
</table><p></p>';
}
}
?>


On Feb 7, 2007, at 10:52 AM, Patrick H. Lauke wrote:

Quoting CK <[EMAIL PROTECTED]>:

The following example of using simpleXML to output XML data is strong.
However, would some standards savvy PHP maven guide in outputting the
list in the proper format:

Just having a cursory glance, I'd say that what you want in that central loop is actually a table, not a list ... it's tabular data.

foreach ($xml->foodGroup as $foodGroup){
  echo "<h2>Food group name is " . $foodGroup->groupName . "</h2>";

  echo "<table>
  <thead>
  <tr><th scope="col">Item</th><th scope="col">Quantity</th></tr>
  </thead>
  <tbody>";

  foreach ($foodGroup->item as $foodItem){
    echo "<tr><th scope="row">" . $foodItem->name . "</th>";
    echo "<td>" . $foodItem->howMuch . "</td></tr>";
  }

  echo "</tbody>";

}

P
--
Patrick H. Lauke
__________________________________________________________
re·dux (adj.): brought back; returned. used postpositively
[latin : re-, re- + dux, leader; see duke.]
www.splintered.co.uk | www.photographia.co.uk
http://redux.deviantart.com
__________________________________________________________
Web Standards Project (WaSP) Accessibility Task Force
http://webstandards.org/
__________________________________________________________


*******************************************************************
List Guidelines: http://webstandardsgroup.org/mail/guidelines.cfm
Unsubscribe: http://webstandardsgroup.org/join/unsubscribe.cfm
Help: [EMAIL PROTECTED]
*******************************************************************




*******************************************************************
List Guidelines: http://webstandardsgroup.org/mail/guidelines.cfm
Unsubscribe: http://webstandardsgroup.org/join/unsubscribe.cfm
Help: [EMAIL PROTECTED]
*******************************************************************

Reply via email to