silkfire Posted May 1, 2011 Share Posted May 1, 2011 I know how to parse and print out contents of an XML file with SimpleXML but when I do it with this one I just get an empty string. XML file sample: <?xml version="1.0"?> <?mso-application progid="Excel.Sheet"?> <Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet" xmlns:html="http://www.w3.org/TR/REC-html40"> <DocumentProperties xmlns="urn:schemas-microsoft-com:office:office"> <Title>Periodens vara - maj</Title> <Company>Company1</Company> <Version>1.00</Version> </DocumentProperties> <OfficeDocumentSettings xmlns="urn:schemas-microsoft-com:office:office"> <AllowPNG/> </OfficeDocumentSettings> <ExcelWorkbook xmlns="urn:schemas-microsoft-com:office:excel"> <WindowHeight>10005</WindowHeight> <WindowWidth>10005</WindowWidth> <WindowTopX>120</WindowTopX> <WindowTopY>135</WindowTopY> <ProtectStructure>False</ProtectStructure> <ProtectWindows>False</ProtectWindows> </ExcelWorkbook> <Styles> <Style ss:ID="Default" ss:Name="Normal"> <Alignment ss:Vertical="Bottom"/> <Font ss:FontName="Calibri" ss:Size="11" ss:Color="#000000"/> </Style> .... I get no error so the structure is correct. But doing print_r() returns an empty array. So does children(). How do I start, help me out Quote Link to comment https://forums.phpfreaks.com/topic/235263-parsing-xml-file/ Share on other sites More sharing options...
firedealer Posted May 1, 2011 Share Posted May 1, 2011 You didn't post a php code. So, I assume you are looking for this: <?php $xmlFeed = 'workbook.xml'; $xmlFeed = simplexml_load_file($xmlFeed); ?> <html> <head></head> <body> <pre><? print_r ( $xmlFeed ); ?></pre> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/235263-parsing-xml-file/#findComment-1208984 Share on other sites More sharing options...
silkfire Posted May 1, 2011 Author Share Posted May 1, 2011 I solved it but you're being a smartass, firedealer, don't you think I tried that way? It's namespaces they complicate everything. Quote Link to comment https://forums.phpfreaks.com/topic/235263-parsing-xml-file/#findComment-1208985 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.