Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> pobieranie rekordów z XML'a, problem z nagłówkiem
raval
post
Post #1





Grupa: Zarejestrowani
Postów: 100
Pomógł: 0
Dołączył: 1.04.2011

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


Witam,

Napisałem skrypt pobierający rekordy z pliku XML.

  1. $xml = simplexml_load_file('sample.xml');
  2. $xml = $xml->offer[0];
  3.  
  4.  
  5. foreach($xml as $key => $value)
  6. {
  7.  
  8. $dl_xml_offer[$key] = $value;
  9. }
  10.  
  11. ...


Wszystko działa poprawnie, jeżeli plik XML jest pozbawiony nagłówka i stopki

  1. <pasaz:Envelope>
  2. <pasaz:Body>
  3. <loadOffers>
  4.  
  5. ...
  6.  
  7. </loadOffers> </pasaz:Body> </pasaz:Envelope>


Czy mogłbym prosić o ewentualną pomoc jak przypisać w skrypcie PHP w/w nagłowek wraz ze stopka, ponieważ wyczerpały mi się już pomysły..

Poniżej załączam plik xml:

  1. <pasaz:Envelope>
  2. <pasaz:Body>
  3. <loadOffers>
  4.  
  5. <offers>
  6.  
  7. <offer>
  8. <id>35</id>
  9. <name>Goodyear Ultra Grip 7+ 195/65/R15 91 T</name>
  10. <price>289,10</price>
  11. <url>http://www.sklep.pl/id=35</url>
  12. <categoryId>Motoryzacja/Opony/Opony osobowe/Opony osobowe zimowe</categoryId>
  13. <description>Gęste ożebrowanie typu Waffle Blades,</description>
  14. <image>http://www.sklep.tel.pl/jpg=35</image>
  15.  
  16.  
  17. <attributes>
  18.  
  19. <attribute>
  20. <name>Producent</name>
  21. <value>Goodyear</value>
  22. </attribute>
  23.  
  24. <attribute>
  25. <name>SAP</name>
  26. <value>515630</value>
  27. </attribute>
  28.  
  29. <attribute>
  30. <name>EAN</name>
  31. <value>5911234567890</value>
  32. </attribute>
  33.  
  34. </attributes>
  35.  
  36. <availability>1</availability>
  37.  
  38. </offer>
  39.  
  40.  
  41. <offer>
  42.  
  43. <id>36</id>
  44.  
  45. <name> Sena Magnetic 13'' </name>
  46. <price>25,54</price>
  47. <url> <a href="http://www.sklep.pl/id=36" target="_blank">http://www.sklep.pl/id=36</a> </url>
  48. <categoryId> Motoryzacja/Felgi i kołpaki/Kołpaki </categoryId>
  49. <description> Kołpak srebne </description>
  50. <image> <a href="http://www.sklep.tel.pl/jpg=36" target="_blank">http://www.sklep.tel.pl/jpg=36</a> </image>
  51.  
  52. <attributes>
  53.  
  54. <attribute>
  55. <name> Producent </name>
  56. <value> Sena </value>
  57. </attribute>
  58.  
  59. <attribute>
  60. <name> Kod producenta </name>
  61. <value> SEA54SD </value>
  62. </attribute>
  63.  
  64. <attribute> <name> EAN </name>
  65. <value> 5911234567890 </value>
  66. </attribute>
  67.  
  68. </attributes>
  69.  
  70. <availability>1</availability>
  71.  
  72. </offer>
  73. </offers>
  74.  
  75. </loadOffers> </pasaz:Body> </pasaz:Envelope>
Go to the top of the page
+Quote Post

Posty w temacie


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: 24.12.2025 - 11:42