SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    Non-Member
    Join Date
    Oct 2005
    Location
    INDIA
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    XML Parsing and Display in a table

    Hi all,

    here is an XML structure,i want tp parse this an display in a table



    <Pressrelease>

    -<Date id="10-18-2005">
    <News head="Test" targetURL="http://loc.com/as.asp">
    fhdfhfdh
    </News>

    <News head="test" targetURL="http://jsljfs.com/ssf.asp">
    fdhdhdf
    </News>
    </Date>

    <Date id="10-15-2005">
    <News head="fusion" targetURL="http://loc.com/as.asp">
    fhdfhfdh
    </News>
    </Date>

    </Pressrelease>


    The display should be like this

    Date 10-18-2005
    Test
    fhdfhfdh More..(on clicking more the link the page that shoud follow is http://loc.com/as.asp)

    Test
    fhdfhfdh More..(on clicking more the link the page that shoud follow is http://jsljfs.com/ssf.asp)


    Date 10-15-2005
    fusion
    fhdfhfdh More

    and so on........

    is this parsing possible
    can any one help me on this


    thank you
    jos

  2. #2
    SitePoint Enthusiast
    Join Date
    Aug 2005
    Posts
    62
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes it is possible to do what you want, but it would be rather difficult. You would probably want to use regular expressions (regex, for short).

    However a better way would be to format your data using an .xsl file. What this does is pretty much exactly what you're looking for. It formats an xml (data) file into html (presentation and data) by defining how the data should be presented. If you take the time to learn a bit about this, I'm sure you will be very pleased.

    http://www.w3schools.com/xsl/

  3. #3
    SitePoint Enthusiast
    Join Date
    Aug 2005
    Posts
    62
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hey, I found out that there is an easy way to do what you want if you're using version 5 of PHP. There's an extension called SimpleXML that will help you out greatly - it stores the xml elements like an array, which makes it easy to call them. Nevertheless, I still think that xsl stylesheets would be of more use to you, as they're built for exactly what you're doing.


Bookmarks

Posting Permissions

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