473,386 Members | 1,841 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 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 17550
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 easier, but not feasible for this project). So I...
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. Unfortunately, it's not working. Here is a portion of the...
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 page. I'm wondering if there's a way to include...
5
by: hijwel | last post by:
<script language="JavaScript"> <!-- document.write('<form name="combo"><select name="example" size="1 onChange="Draw()">'); document.write('<option value=none>Maak je keuze');...
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 have to refresh the page every week to have it...
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 the code from various web examples and modified...
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 a higher level of js knowledge than I've got. ...
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 transform the xml into the output I want, I have 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 named foo.shtml I want to derive the following...
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 allows users to upload a simple html document...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

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.