XML Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreXML Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now!
  #1  
Old March 23rd, 2003, 01:43 PM
camcim camcim is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2002
Location: Melbourne, Australia
Posts: 290 camcim User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 15 h 43 m 46 sec
Reputation Power: 7
Formating xml results passed from a php parser script

Hi guys,
How can i format my results when parsing xml to PHP?
At the moment the value for $data is not formated.
I was wanting to put line breaks after each <slide>.
Here is the xml file:
PHP Code:
<presentations id="root">
   <
presentation>
     <
slide>
       <
name>Picture 1</name>
       <
jpegurl>images/pic_1.swf</jpegurl>
     </
slide>
     <
slide>
       <
name>Picture 2</name>
       <
jpegurl>images/pic_2.swf</jpegurl>
     </
slide>
     <
slide
       <
name>Picture 3</name
       <
jpegurl>images/pic_3.swf</jpegurl>
     </
slide>
     <
slide
       <
name>Picture 4</name
       <
jpegurl>images/pic_4.swf</jpegurl>
     </
slide>
     <
slide
       <
name>Picture 5</name
       <
jpegurl>images/pic_5.swf</jpegurl>
     </
slide>
     <
slide
       <
name>Picture 6</name
       <
jpegurl>images/pic_6.swf</jpegurl>
     </
slide>
     <
slide
       <
name>Picture 7</name
       <
jpegurl>images/pic_7.swf</jpegurl>
     </
slide>
     <
slide
       <
name>Picture 8</name
       <
jpegurl>images/pic_8.swf</jpegurl>
     </
slide>
     <
slide
       <
name>Picture 9</name
       <
jpegurl>images/pic_9.swf</jpegurl>
     </
slide>
   </
presentation>
</
presentations

and here is the php parser code:
PHP Code:
<?
$xml_file 
"xml/images.xml";
?>
<title>Ford - Image Viewer</title>
   
<p><b>Welcome to FORD Image Viewer - Administration</b><br>
------------------------------------------------------</p><br>

<table width="750" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td width="150" bgcolor="#CCCCCC"><font size="1" face="Verdana, Arial, Helvetica, sans-serif"><strong>&nbsp;&nbsp;SLIDE 
      NAME</strong></font></td>
    <td width="300" bgcolor="#CCCCCC"><font size="1" face="Verdana, Arial, Helvetica, sans-serif"><strong>&nbsp;&nbsp;IMAGE 
      FILE NAME</strong></font></td>
    <td width="300">&nbsp;&nbsp;<img src="add_button.jpg" width="60" height="20" align="middle"></td>
  </tr>
</table>
 
<?

function characterData($parser_instance$xml_data) {    
echo 
"$xml_data"
}
 
$parser xml_parser_create();
 
xml_set_character_data_handler($parser"characterData");
if (!(
$filehandler fopen($xml_file"r"))) {    
die(
"could not open XML input"); 
}
while (
$data fread($filehandler4096)) {    
if (!
xml_parse($parser$datafeof($filehandler))) {        
die(
sprintf("XML error: %s at line %d",                    
xml_error_string(xml_get_error_code($parser)),                    
xml_get_current_line_number($parser)));    

}
fclose($filehandler); 
xml_parser_free($parser);
echo 
"</table>";
?>


Any comments greatly appreciated.

Cheers,
camcim

Reply With Quote
  #2  
Old March 29th, 2003, 05:18 AM
a.koepke's Avatar
a.koepke a.koepke is offline
Second highest poster :p
Dev Shed God 5th Plane (7000 - 7499 posts)
 
Join Date: Jul 2001
Posts: 7,323 a.koepke User rank is Sergeant (500 - 2000 Reputation Level)a.koepke User rank is Sergeant (500 - 2000 Reputation Level)a.koepke User rank is Sergeant (500 - 2000 Reputation Level)a.koepke User rank is Sergeant (500 - 2000 Reputation Level)a.koepke User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 8 h 8 m 45 sec
Reputation Power: 27
Look at the XML / PHP manual entry

http://www.php.net/manual/en/ref.xml.php

They show you how to trap the start and end tags. From there use a case statement to apply your formatting

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreXML Programming > Formating xml results passed from a php parser script


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway