473,721 Members | 4,008 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 17606
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 type="text/javascript"> .......lots of code here if (x.TPNroute == "peripheral") {
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 / November 2003"
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, etc.... Thanks, Weston
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'); document.write('<option value="drie">Trend 3'); document.write('</select>');
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 would work if it's possible to do it by week without writing 52 seperate lines, one for each week 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 code works OK when I test it using Frontpage's 'Preview' but does not work when I display the page...
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 duplicate the code in each file, however, it would obviously be preferable to including the routine in...
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" href="Questions.xsl"?> --> I have to
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 page does not refresh to reflect those changes, even if the user hits refresh in their browse....
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.