Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [XML][PHP]PHP do XML, znacznik image z "href"
Delleg
post
Post #1





Grupa: Zarejestrowani
Postów: 25
Pomógł: 0
Dołączył: 22.01.2013

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


Najpierw kod

  1. $xml=new Domdocument("1.0" );
  2. $xml->encoding="UTF-8";
  3. $xml->formatOutput=true;
  4. $coffins=$xml->createElement("coffins");
  5. $xml->appendChild($coffins);
  6.  
  7. $size = $row['size'];
  8. $coffin=$xml->createElement("coffin");
  9. //$coffin->setAttribute("image", $winpath);
  10. $coffin->setAttribute("Kategorie", $cat);
  11. $coffins->appendChild($coffin);
  12. $name=$xml->createElement("name",$name);
  13. $coffin->appendChild($name);
  14. $image=$xml->createElement("PSD", $winpath );
  15. //$coffin->appendChild($image);
  16. $xcat=$xml->createElement("category",$cat);
  17. $coffin->appendChild($xcat);
  18. $xtype=$xml->createElement("type",$type);
  19. $coffin->appendChild($xtype);
  20. $xverb=$xml->createElement("veneered",$verb);
  21. $coffin->appendChild($xverb);
  22. $xsize=$xml->createElement("Überbreite",$size);
  23. $coffin->appendChild($xsize);


powyższy kod tworzy plik XML (podaję tylko wycinek)

  1. <coffin Kategorie="Kiefer">
  2. <name>No. 29 Kiefer Eiche furniert mit Palme Ornament</name>
  3. <image>href="file:///coffins/coffin_id_1.psd"</image>
  4. <category>Kiefer</category>
  5. <type>Furniert</type>
  6. <veneered>Eiche</veneered>
  7. <Size>2000x700x640</Size>
  8. </coffin>


Problem w tym że zamiast <image>href="file:///coffins/coffin_id_1.psd"</image> powinno być <image href="file:///coffins/coffin_id_1.psd"/>, jak to wykonać?

Ten post edytował Delleg 8.11.2016, 00:52:07
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi (1 - 2)
KsaR
post
Post #2





Grupa: Zarejestrowani
Postów: 520
Pomógł: 102
Dołączył: 15.07.2014
Skąd: NULL

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


  1. $image = $xml->createElement('image');
  2. $href = $xml->createAttribute('href');
  3. $href->value = 'file:///coffins/coffin_id_1.psd';
  4. $image->appendChild($href);
  5. $coffin->appendChild($image);



--------------------
Go to the top of the page
+Quote Post
Delleg
post
Post #3





Grupa: Zarejestrowani
Postów: 25
Pomógł: 0
Dołączył: 22.01.2013

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


Cytat(KsaR @ 8.11.2016, 06:56:59 ) *
  1. $image = $xml->createElement('image');
  2. $href = $xml->createAttribute('href');
  3. $href->value = 'file:///coffins/coffin_id_1.psd';
  4. $image->appendChild($href);
  5. $coffin->appendChild($image);

Rzeczywiście banalnie proste, dziękuje Ci bardzo za pomoc. W moim przypadku wartość value to winpath
efekt końcowy to:

  1. <coffin Kategorie="Kiefer">
  2. <name>No. 29 Kiefer Eiche furniert mit Palme Ornament</name>
  3. <image href="href="file:///trumny/coffin_id_1.psd"/>
  4. <category>Kiefer</category>
  5. <type>Furniert</type>
  6. <veneered>Eiche</veneered>
  7. <Size>2000x700x640</Size>
  8. </coffin>


Ten post edytował Delleg 8.11.2016, 09:52:25
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 Aktualny czas: 19.08.2025 - 06:54