Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [XML][PHP] wyświetlenie danych - rozwiązane
Ciubas
post 6.06.2011, 21:08:40
Post #1





Grupa: Zarejestrowani
Postów: 40
Pomógł: 0
Dołączył: 14.09.2003
Skąd: K-ce

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


Witam,

mam taki problem, mniej więcej już rozumiem XML i jak mam inny format danych jest okey, ale tego totalnie nie rozumiem:

  1. <teryt>
  2. <catalog name="TERC" type="all" date="2011-01-01">
  3. <row>
  4. <col name="WOJ">
  5. 02
  6. </col>
  7. <col name="POW"/>
  8. <col name="GMI"/>
  9. <col name="RODZ"/>
  10. <col name="NAZWA">
  11. DOLNOŚLĄSKIE
  12. </col>
  13. <col name="NAZDOD">
  14. województwo
  15. </col>
  16. <col name="STAN_NA">
  17. 2011-01-01
  18. </col>
  19. </row>
  20. <row>
  21. <col name="WOJ">
  22. 02
  23. </col>
  24. <col name="POW">
  25. 01
  26. </col>
  27. <col name="GMI"/>
  28. <col name="RODZ"/>
  29. <col name="NAZWA">
  30. bolesławiecki
  31. </col>
  32. <col name="NAZDOD">
  33. powiat
  34. </col>
  35. <col name="STAN_NA">
  36. 2011-01-01
  37. </col>
  38. </row>
  39. ...


Jest to fragment danych z: http://www.stat.gov.pl/broker/access/prefi...stPreFiles.jspa -> TERC

W jaki sposób mam wypisać wszystkie dane, np:

woj i nazwa (w sumie to potrzebuję), po kolei?

  1. <?php
  2. $xml = simplexml_load_file('TERC.xml');
  3. foreach ($xml->catalog as $e) {
  4. echo $e->NAZWA;
  5. }


To mi nie chce działaćsad.gif

Dzięki pomocy znajomego, sobie poradziłem smile.gif

  1. <?php
  2. $xml = simplexml_load_file('SIMC.xml');
  3. ini_set("memory_limit","1024M");
  4.  
  5.  
  6.  
  7. function objectsIntoArray($arrObjData, $arrSkipIndices = array()) {
  8. $arrData = array();
  9.  
  10. // if input is object, convert into array
  11. if (is_object($arrObjData)) {
  12. $arrObjData = get_object_vars($arrObjData);
  13. }
  14.  
  15. if (is_array($arrObjData)) {
  16. foreach ($arrObjData as $index => $value) {
  17. if (is_object($value) || is_array($value)) {
  18. $value = objectsIntoArray($value, $arrSkipIndices); // recursive call
  19. }
  20. if (in_array($index, $arrSkipIndices)) {
  21. continue;
  22. }
  23. $arrData[$index] = $value;
  24. }
  25. }
  26. return $arrData;
  27. }
  28.  
  29. $xml2 = objectsIntoArray( $xml );
  30.  
  31. for ($i = 0;$i <103209; $i++){
  32.  
  33. echo $i . ' ' . $xml2['catalog']['row'][$i]['col'][0] . ' ' . $xml2['catalog']['row'][$i]['col'][6] . '<br>';
  34. }
  35.  
  36.  
  37.  
  38.  
  39. ?>


Ten post edytował Ciubas 6.06.2011, 21:09:05
Go to the top of the page
+Quote Post
bigtoe88
post 28.06.2011, 08:46:38
Post #2





Grupa: Zarejestrowani
Postów: 1
Pomógł: 0
Dołączył: 28.06.2011

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


I disagree with your opinionin this blog it is too far out there.
kids playhouse


--------------------
kids playhouse
Go to the top of the page
+Quote Post

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

 



RSS Wersja Lo-Fi Aktualny czas: 19.06.2024 - 08:52