Como ler um arquivo XML
23/03/2016
0
Estou com uma duvida que está me custando muito tempo. Eu tenho um arquivo xml em um web service, esse arquivo é de uma planilha do excel. Quando ele é gerado ficam algumas tags com os estilos das células, como cor de fundo, cor da fonte, etc. Eu consigo ler cada celula do arquivo, porém não sei como pegar os esses estilos, somente o conteúdo de cada celula e colocar em uma tabela com o html e o php. Alguém poderia me ajudar ?
Grato.
Matheus Marcelino
Post mais votado
28/03/2016
http://php.net/manual/pt_BR/function.simplexml-load-file.php
Fabiano Carvalho
Mais Posts
23/03/2016
William
24/03/2016
Matheus Marcelino
<?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"> <Styles> <Style ss:ID="Default" ss:Name="Normal"> <Alignment ss:Vertical="Bottom"/> <Borders/> <Font ss:FontName="Calibri" x:Family="Swiss" ss:Size="11" ss:Color="#000000"/> <Interior/> <NumberFormat/> <Protection/> </Style> <Style ss:ID="sDtDefault"> <NumberFormat ss:Format="Short Date"/> </Style> <Style ss:ID="s001"> <Borders> <Border ss:Position="Top" ss:LineStyle="Continuous" ss:Weight="1"/> <Border ss:Position="Bottom" ss:LineStyle="Continuous" ss:Weight="1"/> </Borders> <Font ss:FontName="Arial" ss:Size="08" ss:Color="#363636" ss:Bold="1" /> </Style> <Style ss:ID="s002"> <Borders> <Border ss:Position="Top" ss:LineStyle="Continuous" ss:Weight="1"/> <Border ss:Position="Bottom" ss:LineStyle="Continuous" ss:Weight="1"/> </Borders> <Font ss:FontName="Arial" ss:Size="08" ss:Color="#363636" /> </Style> </Styles> <Worksheet ss:Name="Plan1"> <Table ss:ExpandedColumnCount="14" ss:ExpandedRowCount="14"> <Row ss:AutoFitHeight="0"> <Cell ss:StyleID="s001"><Data ss:Type="String">Total Country</Data></Cell> <Cell ss:StyleID="s001"><Data ss:Type="String">Jan-15</Data></Cell> <Cell ss:StyleID="s001"><Data ss:Type="String">Fev-15</Data></Cell> <Cell ss:StyleID="s001"><Data ss:Type="String">Mar-15</Data></Cell> <Cell ss:StyleID="s001"><Data ss:Type="String">Abr-15</Data></Cell> <Cell ss:StyleID="s001"><Data ss:Type="String">Mai-15</Data></Cell> <Cell ss:StyleID="s001"><Data ss:Type="String">Jun-15</Data></Cell> <Cell ss:StyleID="s001"><Data ss:Type="String">Jul-15</Data></Cell> <Cell ss:StyleID="s001"><Data ss:Type="String">Ago-15</Data></Cell> <Cell ss:StyleID="s001"><Data ss:Type="String">Set-15</Data></Cell> <Cell ss:StyleID="s001"><Data ss:Type="String">Out-15</Data></Cell> <Cell ss:StyleID="s001"><Data ss:Type="String">Nov-15</Data></Cell> <Cell ss:StyleID="s001"><Data ss:Type="String">Dez-15</Data></Cell> <Cell ss:StyleID="s001"><Data ss:Type="String">2015</Data></Cell> </Row> <Row ss:AutoFitHeight="0"> <Cell ss:StyleID="s001"><Data ss:Type="String">Cogs </Data></Cell> <Cell ss:StyleID="s001"><Data ss:Type="Number">531878.56</Data></Cell> <Cell ss:StyleID="s001"><Data ss:Type="Number">535733.19</Data></Cell> <Cell ss:StyleID="s001"><Data ss:Type="Number">580372.44</Data></Cell> <Cell ss:StyleID="s001"><Data ss:Type="Number">569376.56</Data></Cell> <Cell ss:StyleID="s001"><Data ss:Type="Number">658649.75</Data></Cell> <Cell ss:StyleID="s001"><Data ss:Type="Number">618889.91</Data></Cell> <Cell ss:StyleID="s001"><Data ss:Type="Number">667958.53</Data></Cell> <Cell ss:StyleID="s001"><Data ss:Type="Number">708814.86</Data></Cell> <Cell ss:StyleID="s001"><Data ss:Type="Number">632202.84</Data></Cell> <Cell ss:StyleID="s001"><Data ss:Type="Number">760331.69</Data></Cell> <Cell ss:StyleID="s001"><Data ss:Type="Number">692376.01</Data></Cell> <Cell ss:StyleID="s001"><Data ss:Type="Number">789310.4</Data></Cell> <Cell ss:StyleID="s001"><Data ss:Type="Number">7745894.74</Data></Cell> </Row> <Row ss:AutoFitHeight="0"> <Cell ss:StyleID="s002"><Data ss:Type="String">Stocks </Data></Cell> <Cell ss:StyleID="s002"><Data ss:Type="Number">-261953.18</Data></Cell> <Cell ss:StyleID="s002"><Data ss:Type="Number">-268185.38</Data></Cell> <Cell ss:StyleID="s002"><Data ss:Type="Number">-269640.73</Data></Cell> <Cell ss:StyleID="s002"><Data ss:Type="Number">-317593.94</Data></Cell> <Cell ss:StyleID="s002"><Data ss:Type="Number">-346081.24</Data></Cell> <Cell ss:StyleID="s002"><Data ss:Type="Number">-337796.82</Data></Cell> <Cell ss:StyleID="s002"><Data ss:Type="Number">-357958.31</Data></Cell> <Cell ss:StyleID="s002"><Data ss:Type="Number">-306373.9</Data></Cell> <Cell ss:StyleID="s002"><Data ss:Type="Number">-357534.78</Data></Cell> <Cell ss:StyleID="s002"><Data ss:Type="Number">-364186.28</Data></Cell> <Cell ss:StyleID="s002"><Data ss:Type="Number">-426123.04</Data></Cell> <Cell ss:StyleID="s002"><Data ss:Type="Number">-313347.07</Data></Cell> <Cell ss:StyleID="s002"><Data ss:Type="Number">-3926774.67</Data></Cell> </Row> <Row ss:AutoFitHeight="0"> <Cell ss:StyleID="s001"><Data ss:Type="String">days of cogs </Data></Cell> <Cell ss:StyleID="s001"><Data ss:Type="Number">-14.78</Data></Cell> <Cell ss:StyleID="s001"><Data ss:Type="Number">-15.02</Data></Cell> <Cell ss:StyleID="s001"><Data ss:Type="Number">-13.94</Data></Cell> <Cell ss:StyleID="s001"><Data ss:Type="Number">-16.73</Data></Cell> <Cell ss:StyleID="s001"><Data ss:Type="Number">-15.76</Data></Cell> <Cell ss:StyleID="s001"><Data ss:Type="Number">-16.37</Data></Cell> <Cell ss:StyleID="s001"><Data ss:Type="Number">-16.08</Data></Cell> <Cell ss:StyleID="s001"><Data ss:Type="Number">-12.97</Data></Cell> <Cell ss:StyleID="s001"><Data ss:Type="Number">-16.97</Data></Cell> <Cell ss:StyleID="s001"><Data ss:Type="Number">-14.37</Data></Cell> <Cell ss:StyleID="s001"><Data ss:Type="Number">-18.46</Data></Cell> <Cell ss:StyleID="s001"><Data ss:Type="Number">-11.91</Data></Cell> <Cell ss:StyleID="s001"><Data ss:Type="Number">-15.21</Data></Cell> </Row> <Row ss:AutoFitHeight="0"> <Cell ss:StyleID="s002"><Data ss:Type="String">Trade receivables </Data></Cell> <Cell ss:StyleID="s002"><Data ss:Type="Number">-132043.18</Data></Cell> <Cell ss:StyleID="s002"><Data ss:Type="Number">-153131</Data></Cell> <Cell ss:StyleID="s002"><Data ss:Type="Number">-134512.77</Data></Cell> <Cell ss:StyleID="s002"><Data ss:Type="Number">-130289.48</Data></Cell> <Cell ss:StyleID="s002"><Data ss:Type="Number">-149718.96</Data></Cell> <Cell ss:StyleID="s002"><Data ss:Type="Number">-158275.18</Data></Cell> <Cell ss:StyleID="s002"><Data ss:Type="Number">-150273.18</Data></Cell> <Cell ss:StyleID="s002"><Data ss:Type="Number">-166645.04</Data></Cell> <Cell ss:StyleID="s002"><Data ss:Type="Number">-150904.28</Data></Cell> <Cell ss:StyleID="s002"><Data ss:Type="Number">-181843.11</Data></Cell> <Cell ss:StyleID="s002"><Data ss:Type="Number">-179036.69</Data></Cell> <Cell ss:StyleID="s002"><Data ss:Type="Number">0</Data></Cell> <Cell ss:StyleID="s002"><Data ss:Type="Number">-1686672.87</Data></Cell> </Row> <Row ss:AutoFitHeight="0"> <Cell ss:StyleID="s001"><Data ss:Type="String">days of cogs </Data></Cell> <Cell ss:StyleID="s001"><Data ss:Type="Number">-7.45</Data></Cell> <Cell ss:StyleID="s001"><Data ss:Type="Number">-8.58</Data></Cell> <Cell ss:StyleID="s001"><Data ss:Type="Number">-6.95</Data></Cell> <Cell ss:StyleID="s001"><Data ss:Type="Number">-6.86</Data></Cell> <Cell ss:StyleID="s001"><Data ss:Type="Number">-6.82</Data></Cell> <Cell ss:StyleID="s001"><Data ss:Type="Number">-7.67</Data></Cell> <Cell ss:StyleID="s001"><Data ss:Type="Number">-6.75</Data></Cell> <Cell ss:StyleID="s001"><Data ss:Type="Number">-7.05</Data></Cell> <Cell ss:StyleID="s001"><Data ss:Type="Number">-7.16</Data></Cell> <Cell ss:StyleID="s001"><Data ss:Type="Number">-7.17</Data></Cell> <Cell ss:StyleID="s001"><Data ss:Type="Number">-7.76</Data></Cell> <Cell ss:StyleID="s001"><Data ss:Type="Number">0</Data></Cell> <Cell ss:StyleID="s001"><Data ss:Type="Number">-6.53</Data></Cell> </Row> <Row ss:AutoFitHeight="0"> <Cell ss:StyleID="s002"><Data ss:Type="String">Suppliers </Data></Cell> <Cell ss:StyleID="s002"><Data ss:Type="Number">444145.99</Data></Cell> <Cell ss:StyleID="s002"><Data ss:Type="Number">474174.15</Data></Cell> <Cell ss:StyleID="s002"><Data ss:Type="Number">455576.08</Data></Cell> <Cell ss:StyleID="s002"><Data ss:Type="Number">238390.18</Data></Cell> <Cell ss:StyleID="s002"><Data ss:Type="Number">350888.18</Data></Cell> <Cell ss:StyleID="s002"><Data ss:Type="Number">283955.34</Data></Cell> <Cell ss:StyleID="s002"><Data ss:Type="Number">307229.66</Data></Cell> <Cell ss:StyleID="s002"><Data ss:Type="Number">252509.41</Data></Cell> <Cell ss:StyleID="s002"><Data ss:Type="Number">315117.95</Data></Cell> <Cell ss:StyleID="s002"><Data ss:Type="Number">350605.18</Data></Cell> <Cell ss:StyleID="s002"><Data ss:Type="Number">373463.4</Data></Cell> <Cell ss:StyleID="s002"><Data ss:Type="Number">326621.31</Data></Cell> <Cell ss:StyleID="s002"><Data ss:Type="Number">4172676.83</Data></Cell> </Row> <Row ss:AutoFitHeight="0"> <Cell ss:StyleID="s001"><Data ss:Type="String">days of cogs </Data></Cell> <Cell ss:StyleID="s001"><Data ss:Type="Number">25.05</Data></Cell> <Cell ss:StyleID="s001"><Data ss:Type="Number">26.55</Data></Cell> <Cell ss:StyleID="s001"><Data ss:Type="Number">23.55</Data></Cell> <Cell ss:StyleID="s001"><Data ss:Type="Number">12.56</Data></Cell> <Cell ss:StyleID="s001"><Data ss:Type="Number">15.98</Data></Cell> <Cell ss:StyleID="s001"><Data ss:Type="Number">13.76</Data></Cell> <Cell ss:StyleID="s001"><Data ss:Type="Number">13.8</Data></Cell> <Cell ss:StyleID="s001"><Data ss:Type="Number">10.69</Data></Cell> <Cell ss:StyleID="s001"><Data ss:Type="Number">14.95</Data></Cell> <Cell ss:StyleID="s001"><Data ss:Type="Number">13.83</Data></Cell> <Cell ss:StyleID="s001"><Data ss:Type="Number">16.18</Data></Cell> <Cell ss:StyleID="s001"><Data ss:Type="Number">12.41</Data></Cell> <Cell ss:StyleID="s001"><Data ss:Type="Number">16.16</Data></Cell> </Row> <Row ss:AutoFitHeight="0"> <Cell ss:StyleID="s002"><Data ss:Type="String">Suppliers receivables </Data></Cell> <Cell ss:StyleID="s002"><Data ss:Type="Number">15302.34</Data></Cell> <Cell ss:StyleID="s002"><Data ss:Type="Number">26291.04</Data></Cell> <Cell ss:StyleID="s002"><Data ss:Type="Number">21723.38</Data></Cell> <Cell ss:StyleID="s002"><Data ss:Type="Number">-8588.66</Data></Cell> <Cell ss:StyleID="s002"><Data ss:Type="Number">-7285.74</Data></Cell> <Cell ss:StyleID="s002"><Data ss:Type="Number">-12377.01</Data></Cell> <Cell ss:StyleID="s002"><Data ss:Type="Number">-29669.24</Data></Cell> <Cell ss:StyleID="s002"><Data ss:Type="Number">-7941.6</Data></Cell> <Cell ss:StyleID="s002"><Data ss:Type="Number">-6801.83</Data></Cell> <Cell ss:StyleID="s002"><Data ss:Type="Number">-5183.79</Data></Cell> <Cell ss:StyleID="s002"><Data ss:Type="Number">-3751.99</Data></Cell> <Cell ss:StyleID="s002"><Data ss:Type="Number">-6756.5</Data></Cell> <Cell ss:StyleID="s002"><Data ss:Type="Number">-25039.6</Data></Cell> </Row> <Row ss:AutoFitHeight="0"> <Cell ss:StyleID="s001"><Data ss:Type="String">days of cogs </Data></Cell> <Cell ss:StyleID="s001"><Data ss:Type="Number">0.86</Data></Cell> <Cell ss:StyleID="s001"><Data ss:Type="Number">1.47</Data></Cell> <Cell ss:StyleID="s001"><Data ss:Type="Number">1.12</Data></Cell> <Cell ss:StyleID="s001"><Data ss:Type="Number">-0.45</Data></Cell> <Cell ss:StyleID="s001"><Data ss:Type="Number">-0.33</Data></Cell> <Cell ss:StyleID="s001"><Data ss:Type="Number">-0.6</Data></Cell> <Cell ss:StyleID="s001"><Data ss:Type="Number">-1.33</Data></Cell> <Cell ss:StyleID="s001"><Data ss:Type="Number">-0.34</Data></Cell> <Cell ss:StyleID="s001"><Data ss:Type="Number">-0.32</Data></Cell> <Cell ss:StyleID="s001"><Data ss:Type="Number">-0.2</Data></Cell> <Cell ss:StyleID="s001"><Data ss:Type="Number">-0.16</Data></Cell> <Cell ss:StyleID="s001"><Data ss:Type="Number">-0.26</Data></Cell> <Cell ss:StyleID="s001"><Data ss:Type="Number">-0.1</Data></Cell> </Row> <Row ss:AutoFitHeight="0"> <Cell ss:StyleID="s002"><Data ss:Type="String">Supppliers net </Data></Cell> <Cell ss:StyleID="s002"><Data ss:Type="Number">459448.33</Data></Cell> <Cell ss:StyleID="s002"><Data ss:Type="Number">500465.19</Data></Cell> <Cell ss:StyleID="s002"><Data ss:Type="Number">477299.46</Data></Cell> <Cell ss:StyleID="s002"><Data ss:Type="Number">229801.52</Data></Cell> <Cell ss:StyleID="s002"><Data ss:Type="Number">343602.44</Data></Cell> <Cell ss:StyleID="s002"><Data ss:Type="Number">271578.33</Data></Cell> <Cell ss:StyleID="s002"><Data ss:Type="Number">277560.42</Data></Cell> <Cell ss:StyleID="s002"><Data ss:Type="Number">244567.81</Data></Cell> <Cell ss:StyleID="s002"><Data ss:Type="Number">308316.12</Data></Cell> <Cell ss:StyleID="s002"><Data ss:Type="Number">345421.39</Data></Cell> <Cell ss:StyleID="s002"><Data ss:Type="Number">369711.41</Data></Cell> <Cell ss:StyleID="s002"><Data ss:Type="Number">319864.81</Data></Cell> <Cell ss:StyleID="s002"><Data ss:Type="Number">4147637.23</Data></Cell> </Row> <Row ss:AutoFitHeight="0"> <Cell ss:StyleID="s001"><Data ss:Type="String">days of cogs </Data></Cell> <Cell ss:StyleID="s001"><Data ss:Type="Number">25.91</Data></Cell> <Cell ss:StyleID="s001"><Data ss:Type="Number">28.03</Data></Cell> <Cell ss:StyleID="s001"><Data ss:Type="Number">24.67</Data></Cell> <Cell ss:StyleID="s001"><Data ss:Type="Number">12.11</Data></Cell> <Cell ss:StyleID="s001"><Data ss:Type="Number">15.65</Data></Cell> <Cell ss:StyleID="s001"><Data ss:Type="Number">13.16</Data></Cell> <Cell ss:StyleID="s001"><Data ss:Type="Number">12.47</Data></Cell> <Cell ss:StyleID="s001"><Data ss:Type="Number">10.35</Data></Cell> <Cell ss:StyleID="s001"><Data ss:Type="Number">14.63</Data></Cell> <Cell ss:StyleID="s001"><Data ss:Type="Number">13.63</Data></Cell> <Cell ss:StyleID="s001"><Data ss:Type="Number">16.02</Data></Cell> <Cell ss:StyleID="s001"><Data ss:Type="Number">12.16</Data></Cell> <Cell ss:StyleID="s001"><Data ss:Type="Number">16.06</Data></Cell> </Row> <Row ss:AutoFitHeight="0"> <Cell ss:StyleID="s002"><Data ss:Type="String">Stores Merchandise Treasury </Data></Cell> <Cell ss:StyleID="s002"><Data ss:Type="Number">65451.97</Data></Cell> <Cell ss:StyleID="s002"><Data ss:Type="Number">79148.81</Data></Cell> <Cell ss:StyleID="s002"><Data ss:Type="Number">73145.96</Data></Cell> <Cell ss:StyleID="s002"><Data ss:Type="Number">-218081.9</Data></Cell> <Cell ss:StyleID="s002"><Data ss:Type="Number">-152197.76</Data></Cell> <Cell ss:StyleID="s002"><Data ss:Type="Number">-224493.67</Data></Cell> <Cell ss:StyleID="s002"><Data ss:Type="Number">-230671.07</Data></Cell> <Cell ss:StyleID="s002"><Data ss:Type="Number">-228451.13</Data></Cell> <Cell ss:StyleID="s002"><Data ss:Type="Number">-200122.94</Data></Cell> <Cell ss:StyleID="s002"><Data ss:Type="Number">-200608</Data></Cell> <Cell ss:StyleID="s002"><Data ss:Type="Number">-235448.32</Data></Cell> <Cell ss:StyleID="s002"><Data ss:Type="Number">6517.74</Data></Cell> <Cell ss:StyleID="s002"><Data ss:Type="Number">-1465810.31</Data></Cell> </Row> <Row ss:AutoFitHeight="0"> <Cell ss:StyleID="s001"><Data ss:Type="String">days of cogs </Data></Cell> <Cell ss:StyleID="s001"><Data ss:Type="Number">3.69</Data></Cell> <Cell ss:StyleID="s001"><Data ss:Type="Number">4.43</Data></Cell> <Cell ss:StyleID="s001"><Data ss:Type="Number">3.78</Data></Cell> <Cell ss:StyleID="s001"><Data ss:Type="Number">-11.49</Data></Cell> <Cell ss:StyleID="s001"><Data ss:Type="Number">-6.93</Data></Cell> <Cell ss:StyleID="s001"><Data ss:Type="Number">-10.88</Data></Cell> <Cell ss:StyleID="s001"><Data ss:Type="Number">-10.36</Data></Cell> <Cell ss:StyleID="s001"><Data ss:Type="Number">-9.67</Data></Cell> <Cell ss:StyleID="s001"><Data ss:Type="Number">-9.5</Data></Cell> <Cell ss:StyleID="s001"><Data ss:Type="Number">-7.92</Data></Cell> <Cell ss:StyleID="s001"><Data ss:Type="Number">-10.2</Data></Cell> <Cell ss:StyleID="s001"><Data ss:Type="Number">0.25</Data></Cell> <Cell ss:StyleID="s001"><Data ss:Type="Number">-5.68</Data></Cell> </Row> </Table> </Worksheet> </Workbook>
Bom essa é a estrutura, eu queria pegar esses styles, mas não faço a minima ideia de como.
29/03/2016
Matheus Marcelino
Clique aqui para fazer login e interagir na Comunidade :)