![]() |
xml..
view.php
PHP Code:
PHP Code:
Code:
<?xml version="1.0" encoding="ISO-8859-1"?>It doesn't give me any error msgs, but it doesn't print the "testing" below the image :S What's wrong? :( |
Your main problem is centered around your use of SimpleXML, I don't think you've fully grasped it yet.
With the XML document provided, when the SimpleXML document is parsed (using your simplexml_load_string) the object is created which represents your XML data. In this case, the $file variable is essentially the <desc ... /> node in the form of a PHP object. If we were to take a look at the object (using print_r($file)) here's what we would see:Code:
SimpleXMLElement Object$file->desc! To put it simply and hopefully in a straightforward way, you would need to use $file['@attributes']['pic'] to get a hold of the pic attribute.Changes PHP Code:
PHP Code:
However, if you're wanting to have descriptions for multiple images in your XML document -- like below -- things will be slightly different. Let us know if that's the case! Do you want multiple descs? (I've just changed the names to make more sense to me.) Code:
<?xml version="1.0" encoding="utf-8"?> |
Yea, actually that is the case, I wanna have more descriptions for other images.
And thanks for the headsup, I think I understand now why it doesn't work. But I still have no idea how to use this with more than 1 description :( |
With more than one description you'd need to lay out the XML document like I suggested above and then go back to looping through the descs (or pics) looking for the right id (there are other ways, but it's probably best to keep things simple for now).
|
BUt I can still use this:
PHP Code:
|
No. Create your XML with multiple descriptions, and the code that you think would work, then show us. :)
|
HAH!
I solved it! :D:D PHP Code:
Code:
<?xml version="1.0" encoding="utf-8"?>Thanks so much!! :D |
| All times are GMT. The time now is 07:29 PM. |
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0