Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.

nadovezivanje xml fajla, php

[es] :: XML :: nadovezivanje xml fajla, php

[ Pregleda: 4051 | Odgovora: 1 ] > FB > Twit

Postavi temu Odgovori

Autor

Pretraga teme: Traži
Markiranje Štampanje RSS

miniplazma

Član broj: 240037
Poruke: 68
*.crnagora.net.



Profil

icon nadovezivanje xml fajla, php02.06.2012. u 22:17 - pre 143 meseci
Imam sledeći XML file :
Code:

<?xml version="1.0" encoding="utf-8"?>
<videoGallery>
<header title="VIDEO GALERIJA"/>
<footer><![CDATA[<font color="#ffffff"><a href="mailto:[email protected]">info<font color="#c0ff00">@</font>loremipsumdolor.com</a></font>]]></footer>
<items>
    <item  item_icon="items/icon5.jpg" item="items/video1.flv" title="Video 1 Category 1"><![CDATA[Opis.]]></item>
</items>
</videoGallery>


Pokušam da dodam novi item sa php, ali ne dobijam odgovarajući.
PHP kod:
Code:

<?php
$xml = simplexml_load_file("content.xml"); //This line will load the XML file.

$sxe = new SimpleXMLElement($xml->asXML()); //In this line it create a SimpleXMLElement object with the source of the XML file.
//The following lines will add a new child and others child inside the previous child created.
$item = $sxe->addChild("item");
$item->addChild("item_icon", "../items/ddk.jpg");
$item->addChild("item", "items/video1.flv");
$item->addChild("title","naslov");
$item->addChild("item","nekakav dygi tekst");
//This next line will overwrite the original XML file with new data added
$sxe->asXML("content2.xml"); 
?>


Nadovezuje ovo:
Code:
<item>
      <item_icon>../items/ddk.jpg</item_icon>
      <item>items/video1.flv</item>
      <title>naslov</title>
      <item>opis</item>
</item>


 
Odgovor na temu

Jbyn4e

Član broj: 422
Poruke: 6049
95.180.97.*



+257 Profil

icon Re: nadovezivanje xml fajla, php03.06.2012. u 06:44 - pre 143 meseci
Koliko vidim tebi treba ne addchild vec addattribute:
http://www.php.net/manual/en/simplexmlelement.addattribute.php

Kad sve ostalo zakaže, pročitaj uputstvo...
 
Odgovor na temu

[es] :: XML :: nadovezivanje xml fajla, php

[ Pregleda: 4051 | Odgovora: 1 ] > FB > Twit

Postavi temu Odgovori

Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.