I'm trying to read in an xml file that for some reason has been modeled in a table structure like so:
<tr id="1">
<td name="Date">10/01/2009</td>
<td name="PromoName">Sample Promo Name</td>
<td name="PromoCode">Sample Promo Code</td>
<td name="PromoLevel" />
</tr>
This is just one sample row, the file has multiple <tr>
blocks and it's all surrounded by <table>
.
How can I read in the values, with all of the lines being named <td>
name
?
You could use simpleXML with an XPath expression.
This would give you all the TD node values that have a name attribute, e.g.
Edit To get through all the Table Rows, you could do something like this:
You might also want to have a look at this article.
Edit Fixed the XPath expression, as Josh suggested.