I have an XML file I'm trying to parse using SimpleXML.
This is my code
//loading the xml string with simplexml function
$xml = simplexml_load_file("vrv-uploads/" . $proj_id . ".xml");
//looping through every row
foreach ($xml->Workbook->Worksheet->Table->Row as $xml_row)
{
echo $xml_row->Cell[0]->Data . '</br>';
}
I've verified that the file opens correctly, but nothing is printed.
Below you can see the xml file in question (I've collapsed Rows after the first as they just repeat on the same format).
My question is: does my code fails to find the date because of those p2
/p3
prefixes? If so, how do I account for those? Or am I missing something else?
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<?mso-application progid="Excel.Sheet"?>
<Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet">
<DocumentProperties xmlns="urn:schemas-microsoft-com:office:office" />
<ExcelWorkbook xmlns="urn:schemas-microsoft-com:office:excel">
<ProtectStucture>False</ProtectStucture>
<ProtectWindows>False</ProtectWindows>
</ExcelWorkbook>
<Styles>
<Style ss:ID="Default" ss:Name="Normal" xmlns:p3="urn:schemas-microsoft-com:office:spreadsheet">
<ss:Font ss:FontName="Arial" ss:Size="10" />
<ss:Alignment ss:Vertical="Top" ss:WrapText="1" />
</Style>
<Style ss:ID="Percent" ss:Name="Percent" xmlns:p3="urn:schemas-microsoft-com:office:spreadsheet">
<ss:NumberFormat ss:Format="0%" />
</Style>
</Styles>
<Worksheet p2:Name="export" xmlns:p2="urn:schemas-microsoft-com:office:spreadsheet">
<p2:Table p2:ExpandedColumnCount="3" p2:ExpandedRowCount="33" p2:FullColumns="1" p2:FullRows="1">
<p2:Column p2:Width="140" />
<p2:Column p2:Width="34" />
<p2:Column p2:Width="300" />
<p2:Row>
<p2:Cell>
<p2:Data p2:Type="String">Model</p2:Data>
</p2:Cell>
<p2:Cell>
<p2:Data p2:Type="String">Qty</p2:Data>
</p2:Cell>
<p2:Cell>
<p2:Data p2:Type="String">Description</p2:Data>
</p2:Cell>
</p2:Row>
</p2:Table>
</Worksheet>
</Workbook>