472,330 Members | 1,485 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,330 software developers and data experts.

Include PHP Code in XML document

228 100+
Hey all,
I am buildin xml based album and i want to include php code into the xml file. The xml file is generated by coffecup and lookks like this:

Expand|Select|Wrap|Line Numbers
  1. <thumbnailer
  2.    x="10"
  3.    y="375"
  4.    w="450"
  5.    h="80"
  6.    myname="thumbs1"
  7.    image1="myalbum/jennifer_aniston_01_s.jpg"
  8.    bigimage1="myalbum/jennifer_aniston_01.jpg"
  9.    imagecaption1="1"
  10.    image2="myalbum/jennifer_aniston_02_s.jpg"
  11.    bigimage2="myalbum/jennifer_aniston_02.jpg"
  12.    imagecaption2="2"
  13.    image3="myalbum/jennifer_aniston_03_s.jpg"
  14.    bigimage3="myalbum/jennifer_aniston_03.jpg"
  15.    imagecaption3="3"
  16.    image4="myalbum/jennifer_aniston_04_s.jpg"
  17.    bigimage4="myalbum/jennifer_aniston_04.jpg"
  18.    imagecaption4="4"
  19.     image5="myalbum/jennifer_aniston_05.jpg"
  20.    bigimage5="myalbum/jennifer_aniston_05.jpg"
  21.    imagecaption5="5"
  22.     image6="myalbum/jennifer_aniston_06.jpg"
  23.    bigimage6="myalbum/jennifer_aniston_06.jpg"
  24.    imagecaption6="6"
  25.   >
  26.   </thumbnailer>
I want to get the images automatically using php. Anyway i can that? Or can i insert XML data into php document?
Dec 13 '08 #1
7 17423
Markus
6,050 Expert 4TB
You can read an .XML file by using any of PHP's built in functions.

PHP: XMLReader - Manual

A google for 'php read xml' will do you fine.
Dec 13 '08 #2
Dormilich
8,658 Expert Mod 8TB
two other PHP classes that deal with XML.

PHP: DOMDocument - Manual

PHP: SimpleXML - Manual

regards
Dec 13 '08 #3
dumm
10
You must sent the xml header to the browser in your php file.

Expand|Select|Wrap|Line Numbers
  1.  
  2. <?php 
  3.  
  4. header("Content-type:text/xml; charset=utf-8");
  5.  
  6. echo '<thumbnailer'>;
  7.  
  8.  
  9. /* PHP code to generate your data goes here */
  10.  
  11.  
  12. echo '</thumbnailer>';
  13.  
  14.  
  15. exit;
  16. ?>
  17.  
Dec 14 '08 #4
samvb
228 100+
@dumm
ur way seems to be easy. but i need to create the file always that means, rgt? My idea is to update only the contents of the <thumbnailer> section of the XML doc (it is a very long,long one). I need to insert the PHP code right in the xml document. Or is it possible to have the php code with XML code in between?
Dec 16 '08 #5
dumm
10
You need to put the xml code into the php file. By sending the xml header to the browser, you tell the browser to render it as an XML document.

To send the XML header to the browser just put this at the top of your php file before any other output :

header("Content-type:text/xml; charset=utf-8");

You CAN'T put php inside XML document BUT you can put xml inside a php document

Hope it clarify!
Dec 16 '08 #6
samvb
228 100+
thats very clear, thankx!
Dec 16 '08 #7
Markus
6,050 Expert 4TB
Or you could just update the <thumbnailer> section by using one of the many XML classes PHP has - like suggested before.
Dec 16 '08 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Andrew V. Romero | last post by:
I am using javascript to parse a form and it uses the information on that form to display some calculations (yes using PHP or something would be...
21
by: Peter Bassett | last post by:
I have a .shtml file, that displays photos, in which I wish to pass some functionality off to an Include file for reusability purposes....
22
by: Weston C | last post by:
I know of course that you can use <script src=""></script> in an HTML document to include javascript code you don't want to spill all over the...
5
by: hijwel | last post by:
<script language="JavaScript"> <!-- document.write('<form name="combo"><select name="example" size="1 onChange="Draw()">');...
21
by: .:mmac:. | last post by:
I have to update a page every week. I get the page ahead of time so I used the "scheduled includes" webbot in Frontpage only to find that I would...
5
by: Tony Strazzeri | last post by:
Hi all, I a fairly new to html and Javascripting. I have been trying to write some code to hide my email address from spam harvesters. I copied...
4
by: Jake j | last post by:
To those of you who sent me working examples of js include routines, much thanks. I see from them examples that what I'm trying to get to requires...
3
by: Gordon Moore | last post by:
Hi, I'm new to using xml/xslt and although I can create an xml document using the dataset.WriteXml statement, and I have created an xslt to...
2
by: newsgroups | last post by:
What I'm trying to do is for each page I want to have a dynamic include that is derived from the current document name. Example, for a page...
3
by: =?Utf-8?B?QnJhbmRvbg==?= | last post by:
Hi, I have an aspx page that has the "include" code in it which includes another page that displays information. I also have an upload page that...
0
by: tammygombez | last post by:
Hey fellow JavaFX developers, I'm currently working on a project that involves using a ComboBox in JavaFX, and I've run into a bit of an issue....
0
by: tammygombez | last post by:
Hey everyone! I've been researching gaming laptops lately, and I must say, they can get pretty expensive. However, I've come across some great...
0
by: concettolabs | last post by:
In today's business world, businesses are increasingly turning to PowerApps to develop custom business applications. PowerApps is a powerful tool...
0
by: teenabhardwaj | last post by:
How would one discover a valid source for learning news, comfort, and help for engineering designs? Covering through piles of books takes a lot of...
0
by: CD Tom | last post by:
This only shows up in access runtime. When a user select a report from my report menu when they close the report they get a menu I've called Add-ins...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
0
jalbright99669
by: jalbright99669 | last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was...
2
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.