Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3

Thread: XML Parsing

  1. #1
    New to the CF scene
    Join Date
    May 2013
    Location
    KGFK
    Posts
    5
    Thanks
    1
    Thanked 0 Times in 0 Posts

    XML Parsing

    I'm new to the forum, but have been reading for a long time. I am new to php but have a solid understanding.I have a php script which parses an XML file, what I am trying to do is convert a record.

    The record is <floc>|airlines|21195|2013|5|12</floc>

    I am only looking to use the |2013|5|12| and change the format to 5/12/2013.

    Any ideas?

    Thanks,

    Tom

  • #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,980
    Thanks
    4
    Thanked 2,659 Times in 2,628 Posts
    I'm confused. Since XML is a descriptive language, why does the record not provide a better description of itself?
    Assuming that you can retrieve the record and that the record is consistent, you can simply use explode and list. I don't know what the values represent though:
    PHP Code:
    list($nullvar$typeMaybe$idMaybe$year$month$day) = explode('|'$flocRecord);
    $dt = new DateTime();
    $dt->setDate($year$month$day);
    print 
    $dt->format('m/d/Y'); 
    Should do what you want.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 

  • Users who have thanked Fou-Lu for this post:

    t_bergman (05-22-2013)

  • #3
    New to the CF scene
    Join Date
    May 2013
    Location
    KGFK
    Posts
    5
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Fou-Lu View Post
    I'm confused. Since XML is a descriptive language, why does the record not provide a better description of itself?
    Assuming that you can retrieve the record and that the record is consistent, you can simply use explode and list. I don't know what the values represent though:
    PHP Code:
    list($nullvar$typeMaybe$idMaybe$year$month$day) = explode('|'$flocRecord);
    $dt = new DateTime();
    $dt->setDate($year$month$day);
    print 
    $dt->format('m/d/Y'); 
    Should do what you want.
    Exactly what I was looking for, its working perfectly. Thanks


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •