473,554 Members | 2,888 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Include PHP Code in XML document

228 New Member
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 17574
6,050 Recognized Expert Expert
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
8,658 Recognized Expert Moderator Expert
two other PHP classes that deal with XML.

PHP: DOMDocument - Manual

PHP: SimpleXML - Manual

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

Expand|Select|Wrap|Line Numbers
  2. <?php 
  4. header("Content-type:text/xml; charset=utf-8");
  6. echo '<thumbnailer'>;
  9. /* PHP code to generate your data goes here */
  12. echo '</thumbnailer>';
  15. exit;
  16. ?>
Dec 14 '08 #4
228 New Member
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
10 New Member
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
228 New Member
thats very clear, thankx!
Dec 16 '08 #7
6,050 Recognized Expert Expert
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

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 would like to include another file on my display page if a certain variable is checked. My code is something like this. <script...
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 .shtml file: ====== <!--#include file="/tmb8/functions.inc"--> <script type="text/javascript"> var title = "Noosa, Australia - October /...
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 other pieces of javascript code from *within* javascript.... a la #include in C, @import in Java, use/require in Perl, include()/require() in PHP,...
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'); document.write('<option value=none>--------------------'); document.write('<option value="een">Trend 1'); document.write('<option value="twee">Trend 2');...
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 work. That is silly, it should run by itself. so... I asked the question in the FP group and I was offered this pseudocode to do it by month which...
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 it to suit me. The code to generate the address is in a js include file. I am using frontpage 2003 to create my web pages. My problem is that the...
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. Here's what I'm really trying to do: I've been using a sliding banner javascript routine in several html files and it works fine. Rather than...
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 manually add the xsl reference statement to the xml file. i.e. <?xml version="1.0" standalone="yes"?> <?xml:stylesheet type="text/xsl"...
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 include statement: <!--#include virtual="/foodir/foo_incl.htm" -->
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 onto the server. The include code calls that html page to display the text on that page. The problem is when the user uploads that html page, the aspx...
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.