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:
  #1  
Old April 2nd, 2004, 08:34 PM
blance blance is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2004
Posts: 1 blance User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Parsing an XML to php

i was look at a xml file which is

click here to view the xml file

can anyone tell me how can i Parse it so that AvgTimeInAge2="309" turn into a time form for example (mins:sec).

I try doing it but it turn out to be 309 instead of mins:sec

thanks

Last edited by blance : April 2nd, 2004 at 08:37 PM.

Reply With Quote
  #2  
Old April 7th, 2004, 07:06 AM
MattSidesinger's Avatar
MattSidesinger MattSidesinger is offline
Java PHP Oracle Developer
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Location: C-Bus OH-IO
Posts: 204 MattSidesinger User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 15 m 26 sec
Reputation Power: 5
Send a message via AIM to MattSidesinger
The XML parser cannot do any mathematical functions, like divide 309 by 60. It only provides an interface so that you can access the XML data as nodes. You will need to obtain the 309 and then divide by 60 in your PHP code, the XML nor the parser can do that on their own.

Reply With Quote
  #3  
Old April 7th, 2004, 09:21 AM
fpmurphy fpmurphy is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Location: USA
Posts: 289 fpmurphy User rank is Corporal (100 - 500 Reputation Level)fpmurphy User rank is Corporal (100 - 500 Reputation Level)fpmurphy User rank is Corporal (100 - 500 Reputation Level)fpmurphy User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 1 Day 3 h 22 m 4 sec
Reputation Power: 6
Here is an example of one way of doing it if you are
using a stylesheet:

Code:
<?xml version="1.0"?>
<time>
        <seconds>309</seconds>
</time>


Code:
<?xml version="1.0" encoding="ISO-8859-1" ?>
 
<xsl:stylesheet version="1.0" 
     xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:output method="html"/>

<xsl:template match="/">
     <xsl:apply-templates select="/time/seconds"/>
</xsl:template>

<xsl:template match="/time/seconds">
     <xsl:value-of select="floor(. div 60)"/>:<xsl:value-of select=". mod 60"/>
</xsl:template>

</xsl:stylesheet>


You can also use the EXSLT extension functions (www.exslt.org)

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreXML Programming > Parsing an XML to php


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 2 hosted by Hostway
Stay green...Green IT