Hi all. i have an xml file as shown below and i want to reference specific data out it.(The data shown in bold)Could any one show me how to reference those data so i can use them later as variables.I not only want to output them all at once.I also want to learn how to reference individual items separately because i have another part that uses those 3 variables(Artistname,songname,songimage).i be happy if some show me how this can be done in php.Thanks
Nico thanks for u reply. But when i run your code i don't get any thing printed on screen. i used echo to test before using those artist ,song and image varible in my remaining program. could tell me what is wrong. The xml is in a remote server.Thanks
I've tested the code locally and it worked for me. The text between the tags will be stored in these variables: $artist, $song, $image. So if you echo them it should display the right content.
Do you get any errors, like the file could not be opened or something? Also, in the XML file is always one set only, as you said, right?
Try echoing $xml too, to see if the XML is alright.
I've tested the code locally and it worked for me. The text between the tags will be stored in these variables: $artist, $song, $image. So if you echo them it should display the right content.
Do you get any errors, like the file could not be opened or something? Also, in the XML file is always one set only, as you said, right?
Try echoing $xml too, to see if the XML is alright.
Nico many thanks i tested it worked so good. The problem was with xml file. It need to be called like localhost/rss.php?xml=true and i was using rss.php only!!
Nico i did a lot of search on web most of the tutorial they talk about outputing the whole xml but they never show how to refrence indvidual items in xml and thanks to you that help me learn this.
This method of parsing XML is only good if there's only one set, like in your case. If there are more, I'd use preg_match_all() to get all items, then I'd loop through them and parse the data in each item. Otherwise it could conflict.
Nico i get in to this problem. When the imageurl has space in image name i get garbage in php. I be happy if u look at it help me fix it.Thanks
Code:
<br />
<b>Warning</b>: imagecreatefromjpeg(./david bob.jpg): failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found
in <b>/home/www/script.php</b> on line <b>27</b><br />
<br />
<b>Warning</b>: imagecopymerge(): supplied argument is not a valid Image resource in <b>/home/www/script.php</b> on line <b>28</b><br />
PNG
IHDRB IDATxy|]Wu?]^I5Y[`Y;s8 $!!$_)B/)Ёh?@[t miZ$JN!vl2cϓdk5[gr~Zs
......
.....