Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> przetwazanie pliku XML
-Guest-
post
Post #1





Goście







chce przetwozyc plik XML a dkoladnie generowany przez Excel wiec wczytuje go przez simplexml i che sie dobrac do atrybutow ale maja one taka postac:
Kod
<Table ss:ExpandedColumnCount="3" ss:ExpandedRowCount="4" x:FullColumns="1"
   x:FullRows="1">
   <Row>
    <Cell><Data ss:Type="String">kolumna1</Data></Cell>
    <Cell ss:MergeAcross="1"><Data ss:Type="String">kolumna2_zlacz</Data></Cell>
   </Row>
   <Row>
    <Cell><Data ss:Type="String">aaa</Data></Cell>
    <Cell><Data ss:Type="String">bbbb</Data></Cell>
    <Cell><Data ss:Type="String">ccc</Data></Cell>
   </Row>
   <Row>
    <Cell><Data ss:Type="String">SSS</Data></Cell>
    <Cell><Data ss:Type="String">SWE</Data></Cell>
    <Cell><Data ss:Type="String">TEST</Data></Cell>
   </Row>
   <Row>
    <Cell><Data ss:Type="String">asas</Data></Cell>
    <Cell><Data ss:Type="String">adad</Data></Cell>
    <Cell><Data ss:Type="String">afaf</Data></Cell>
   </Row>
  </Table>


nie wiem jak sie dobrac do ss:ExpandedColumnCount
  1. <?php
  2. $xml = simplexml_load_file('test.xml');
  3. echo $xml->Table['ExpandedColumnCount'];
  4.  
  5. ?>
to cos takiego nie dziala (IMG:http://forum.php.pl/style_emoticons/default/sad.gif) jak dam $xml->Table['ss:ExpandedColumnCount']; to tez nie (IMG:http://forum.php.pl/style_emoticons/default/sad.gif) wiec jak mam sie do tego dobrac?(IMG:http://forum.php.pl/style_emoticons/default/questionmark.gif)
Go to the top of the page
+Quote Post
tiraeth
post
Post #2





Grupa: Przyjaciele php.pl
Postów: 1 789
Pomógł: 41
Dołączył: 30.10.2003
Skąd: Wrocław

Ostrzeżenie: (0%)
-----


Z tego co widzę po Twoim kodzie php to $xml->Table jest tablicą. Może poprostu potraktuj ją print_r($xml->Table); ?
Go to the top of the page
+Quote Post
NuLL
post
Post #3





Grupa: Zarejestrowani
Postów: 2 262
Pomógł: 21
Dołączył: 3.05.2004
Skąd: Sopot, Krakow, W-wa

Ostrzeżenie: (0%)
-----


  1. <?php
  2. $xml = simplexml_load_file('test.xml');
  3. echo (string)$xml->Table->ExpandedColumnCount;
  4.  
  5. ?>

@tiraeth - nie tablica - ja juz to iteratorem.

Zdravim
Go to the top of the page
+Quote Post
aleksander
post
Post #4





Grupa: Przyjaciele php.pl
Postów: 742
Pomógł: 0
Dołączył: 14.12.2003
Skąd: Gdańsk, Trójmiasto

Ostrzeżenie: (0%)
-----


najwyższy tag jest jako najwyższy obiekt SimpleXML. czytaj: tag table jest obiektem zapisanym w zmiennej $xml czyli:
zamiast $xml->Table['ExpandedColumnCount']
bedzie $xml['ExpandedColumnCount'];
Go to the top of the page
+Quote Post
-Guest-
post
Post #5





Goście







hmm tag wyglada tak:
Kod
<Table ss:ExpandedColumnCount="3" ss:ExpandedRowCount="4" x:FullColumns="1"
  x:FullRows="1">
ja che sie dostac do ss:ExpandedColumnCount czyli otrzymac wartosc 3 (IMG:http://forum.php.pl/style_emoticons/default/smile.gif)
Go to the top of the page
+Quote Post
aleksander
post
Post #6





Grupa: Przyjaciele php.pl
Postów: 742
Pomógł: 0
Dołączył: 14.12.2003
Skąd: Gdańsk, Trójmiasto

Ostrzeżenie: (0%)
-----


$xml['ss:ExpandedColumnCount'] (IMG:http://forum.php.pl/style_emoticons/default/questionmark.gif)
Go to the top of the page
+Quote Post
dr_bonzo
post
Post #7





Grupa: Przyjaciele php.pl
Postów: 5 724
Pomógł: 259
Dołączył: 13.04.2004
Skąd: N/A

Ostrzeżenie: (0%)
-----


Kod aleksandra powinien dzialac, ale nie dziala. Nawet DOMem nie moglem odczytac tego atrybutu -- nie ma takiej opcji.
Go to the top of the page
+Quote Post
-Guest-
post
Post #8





Goście







niebardzo (IMG:http://forum.php.pl/style_emoticons/default/sad.gif)

caly plik XML wyglada tak:
  1. <?xml version="1.0"?>
  2. <?mso-application progid="Excel.Sheet"?>
  3. <Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet"
  4. xmlns:o="urn:schemas-microsoft-com:office:office"
  5. xmlns:x="urn:schemas-microsoft-com:office:excel"
  6. xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet"
  7. xmlns:html="http://www.w3.org/TR/REC-html40">
  8. <DocumentProperties xmlns="urn:schemas-microsoft-com:office:office">
  9. <Author>zzz</Author>
  10. <LastAuthor>zzz</LastAuthor>
  11. <Created>2006-01-15T14:03:24Z</Created>
  12. <Company>niepowiem</Company>
  13. <Version>11.6505</Version>
  14. </DocumentProperties>
  15. <ExcelWorkbook xmlns="urn:schemas-microsoft-com:office:excel">
  16. <WindowHeight>13185</WindowHeight>
  17. <WindowWidth>15120</WindowWidth>
  18. <WindowTopX>480</WindowTopX>
  19. <WindowTopY>30</WindowTopY>
  20. <ProtectStructure>False</ProtectStructure>
  21. <ProtectWindows>False</ProtectWindows>
  22. </ExcelWorkbook>
  23. <Styles>
  24. <Style ss:ID="Default" ss:Name="Normal">
  25. <Alignment ss:Vertical="Bottom"/>
  26. <Borders/>
  27. <Font x:CharSet="238"/>
  28. <Interior/>
  29. <NumberFormat/>
  30. <Protection/>
  31. </Style>
  32. </Styles>
  33. <Worksheet ss:Name="Arkusz1">
  34. <Table ss:ExpandedColumnCount="3" ss:ExpandedRowCount="4" x:FullColumns="1" x:FullRows="1">
  35. <Row>
  36. <Cell><Data ss:Type="String">kolumna 1</Data></Cell>
  37. <Cell><Data ss:Type="String">kolumna 2</Data></Cell>
  38. <Cell><Data ss:Type="String">kolumna 3</Data></Cell>
  39. </Row>
  40. <Row>
  41. <Cell><Data ss:Type="String">aaa</Data></Cell>
  42. <Cell><Data ss:Type="String">bbbb</Data></Cell>
  43. <Cell><Data ss:Type="String">cccc</Data></Cell>
  44. </Row>
  45. <Row>
  46. <Cell><Data ss:Type="String">1q1q1q</Data></Cell>
  47. <Cell><Data ss:Type="String">2w2w2w</Data></Cell>
  48. <Cell><Data ss:Type="String">3e3e3e</Data></Cell>
  49. </Row>
  50. <Row>
  51. <Cell><Data ss:Type="String">zzz</Data></Cell>
  52. <Cell><Data ss:Type="String">xxx</Data></Cell>
  53. <Cell><Data ss:Type="String">qqq</Data></Cell>
  54. </Row>
  55. </Table>
  56. <WorksheetOptions xmlns="urn:schemas-microsoft-com:office:excel">
  57. <PageSetup>
  58. <PageMargins x:Bottom="0.984251969" x:Left="0.78740157499999996"
  59. x:Right="0.78740157499999996" x:Top="0.984251969"/>
  60. </PageSetup>
  61. <Selected/>
  62. <ProtectObjects>False</ProtectObjects>
  63. <ProtectScenarios>False</ProtectScenarios>
  64. </WorksheetOptions>
  65. </Worksheet>
  66. </Workbook>


jest to prosty plik excel zapisany jako xml (IMG:http://forum.php.pl/style_emoticons/default/smile.gif) chce wyciagnac z niego miedzy innymi to ss:ExpandedColumnCount="3" a dokladnie wartosc 3 (IMG:http://forum.php.pl/style_emoticons/default/smile.gif)
  1. <?php
  2.  
  3. $xml = simplexml_load_file('excel.xml');
  4. echo $xml->DocumentProperties->Worksheet->Table['ss:ExpandedColumnCount'];
  5. ?>
to nie dziala (IMG:http://forum.php.pl/style_emoticons/default/sad.gif) ani $xml->DocumentProperties->Worksheet->Table['ExpandedColumnCount'];
Go to the top of the page
+Quote Post
dr_bonzo
post
Post #9





Grupa: Przyjaciele php.pl
Postów: 5 724
Pomógł: 259
Dołączył: 13.04.2004
Skąd: N/A

Ostrzeżenie: (0%)
-----


Teraz to co innego (IMG:http://forum.php.pl/style_emoticons/default/biggrin.gif) .

  1. <?php
  2. $xml = simplexml_load_string( $xmlData );
  3. $attributes = $xml->Worksheet->Table->attributes( 'urn:schemas-microsoft-com:office:spreadsheet' );
  4. $cols = $attributes[ 'ExpandedColumnCount' ];
  5. print( $cols );
  6.  
  7. ?>


Gotcha (IMG:http://forum.php.pl/style_emoticons/default/biggrin.gif)

A wszystko to bylo tutaj (w manualu tez (IMG:http://forum.php.pl/style_emoticons/default/tongue.gif) ):
http://www.sitepoint.com/blogs/2005/10/20/...and-namespaces/
Go to the top of the page
+Quote Post
-Guest-
post
Post #10





Goście







dzieki dr_bonzo dziala (IMG:http://forum.php.pl/style_emoticons/default/smile.gif)

zapewne sie domyslacie po co to robie (IMG:http://forum.php.pl/style_emoticons/default/smile.gif) bo chce w latwy sposob prezentowac arkusze zrobione w Excelu lub OpenOffice Calc na strocnie (IMG:http://forum.php.pl/style_emoticons/default/smile.gif) narazie mam bardzo prototypowy skrypt ale potrafi paczyc komorki oraz wiersze oraz formatowac komorki (tlo, czcionka, polozenie textu) moze juz sa jakies gotowe komponenty do tego jakas klasa albo cos (IMG:http://forum.php.pl/style_emoticons/default/smile.gif)

jesli nie moge zaprezentowac to co mam (IMG:http://forum.php.pl/style_emoticons/default/smile.gif)
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 22.08.2025 - 19:41