PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
nskauto
Forum Newbie
Posts: 4 Joined: Fri May 26, 2006 9:03 am
Post
by nskauto » Fri May 26, 2006 9:12 am
Hello guys, please help me.
I have the flash template for Slideshow, but this template uses XML file, where stored paths to images.
XML:
Code: Select all
<gallery timer="1" order="sequential" fadetime="18" looping="yes" xpos="0" ypos="0">
<image path="images/calliandra.jpg" />
<image path="images/dombeya.jpg" />
<image path="images/strelitzia.jpg" />
<image path="images/trensa.jpg" />
<image path="images/treeflower.jpg" />
<image path="images/bellflowers.jpg" />
<image path="images/cordyline.jpg" />
<image path="images/forsythia.jpg" />
</gallery>
I need to understand a simple PHP code to add automatically tag <image path="blabla"> into this XML file .....
Can anybody help me ?
Thank you all.
xpgeek
Forum Contributor
Posts: 146 Joined: Mon May 22, 2006 1:45 am
Location: Kyiv, Ukraine
Contact:
Post
by xpgeek » Fri May 26, 2006 9:31 am
See
XML with expat
This class is meant to read and write XML documents implementing the DOM API using the PHP XML functions based on the Expat library.
The class is able to open an XML document, parses it, and lets the developer change anything in the document: add nodes, set attributes, remove attributes, clone nodes, insert children, etc..
nskauto
Forum Newbie
Posts: 4 Joined: Fri May 26, 2006 9:03 am
Post
by nskauto » Fri May 26, 2006 9:43 am
I think there are several lines of code.
( Please post this simple lines if you know
xpgeek
Forum Contributor
Posts: 146 Joined: Mon May 22, 2006 1:45 am
Location: Kyiv, Ukraine
Contact:
Post
by xpgeek » Fri May 26, 2006 10:50 am
nskauto wrote: I think there are several lines of code.
( Please post this simple lines if you know
Try it.
Code: Select all
$dom = new DomDocument();
$dom->load("article.xml");
$item = $dom->createElement("image");
$item->setAttribute ('path', 'images/someimage.jpg');
$dom->documentElement->appendChild($item);
print $dom->saveXML();
article.xml look like this
<gallery timer="1" order="sequential" fadetime="18" looping="yes" xpos="0" ypos="0">
<image path="images/calliandra.jpg" />
<image path="images/dombeya.jpg" />
<image path="images/strelitzia.jpg" />
<image path="images/trensa.jpg" />
<image path="images/treeflower.jpg" />
<image path="images/bellflowers.jpg" />
<image path="images/cordyline.jpg" />
<image path="images/forsythia.jpg" />
</gallery>
nskauto
Forum Newbie
Posts: 4 Joined: Fri May 26, 2006 9:03 am
Post
by nskauto » Mon May 29, 2006 1:30 am
But I have such errors
( :
Warning: domdocument() expects at least 1 parameter, 0 given in C:\Inetpub\vhosts\sokieva.bagov.net\httpdocs\test\test.php on line 2
Fatal error: Call to undefined function: load() in C:\Inetpub\vhosts\sokieva.bagov.net\httpdocs\test\test.php on line 3
What happens ?
xpgeek
Forum Contributor
Posts: 146 Joined: Mon May 22, 2006 1:45 am
Location: Kyiv, Ukraine
Contact:
Post
by xpgeek » Mon May 29, 2006 2:13 am
my version php is 5.1.2
nskauto
Forum Newbie
Posts: 4 Joined: Fri May 26, 2006 9:03 am
Post
by nskauto » Mon May 29, 2006 5:37 am
But my PHP Version is 4.3.11.
So in PHP 4 there are others methods and functions
( Can anybody help me with PHP4?