SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Zealot
    Join Date
    Jun 2006
    Posts
    177
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Handling data in XML parser

    Hey, I've got an XML parser that reads an RSS feed, and it should take out the title, date and first paragraph of the latest entry and show that.

    I got it to show all entries, including the header info ( ), and can do HTML formating so that the title's in bold, date's underlined and the actual entry's in italic, but...
    Tim W.tag:blogger.com,1999:blog-8701199.post-29495624028221418612007-05-29T21:48:00.000-07:002007-05-29T05:56:44.338-07:00
    Between the actual entry and the date, I get that, in plain text, so not underlined, italic, or such, except the 2007-05-29T05:56:44.338-07:00 part.

    I'm now wondering how I can keep that out and how I can reformat the 2007-05-29T05:56:44.338-07:00 part to be more readable, plus how I can show the info of only the last entry, and only the first paragraph of the entry. It doesn't seem like I can do that with any function, and the way you have to use a separate function for the data, it doesn't allow you to say: "Handle the data from this tag this way."

    Any help is highly appreciated.

  2. #2
    SitePoint Zealot
    Join Date
    Jun 2006
    Posts
    177
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Anybody got any ideas?

  3. #3
    SitePoint Zealot
    Join Date
    Jun 2006
    Posts
    177
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Anybody?

  4. #4
    SitePoint Evangelist
    Join Date
    Aug 2005
    Posts
    453
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    1. Put the title, date and entry in a blog object. ( Yes I would build a blog class.)
    2. Put all blog objects into an array.
    3. Iterate through the array and get the last timestamp.

    Is the blog marked up with html? Can you use a string function to search for the <p> tag? If not how many spaces is the second paragraph indented?
    Computers and Fire ...
    In the hands of the inexperienced or uneducated,
    the results can be disastrous.
    While the professional can tame, master even conquer.

  5. #5
    SitePoint Zealot
    Join Date
    Jun 2006
    Posts
    177
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The blog uses HTML, yep. Each paragraph's separated by two <br />-tags. There's no such things as a <p>-tag in there, though.

    The class idea's a good one, but it still leaves the problem of telling the data handling function what it's dealing with currently. At the moment, I'm using a global var for that, but that feels like patchwork, not like the way it should be done.

  6. #6
    SitePoint Evangelist
    Join Date
    Aug 2005
    Posts
    453
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    $testdata "W.tag:blogger.com,1999:blog-8701199.post-29495624028221418612007-05-29T21:48:00.000-07:002007-05-29T05:56:44.338-07:00";

    $parts explode"post-"$testdata);
    print_r$parts );
    echo 
    "<br>";

    $post_parts explode"-"$parts[1] );
    print_r$post_parts );
    echo 
    "<br>";

    $post_ID substr$post_parts[0], 0strlen$post_parts[0]-));
    print_r$post_ID );
    echo 
    "<br>";

    $post_Year substr$post_parts[0], -);
    echo 
    "Year : " .$post_Year"<br>" ;

    $post_Month $post_parts[1];
    echo 
    "Month : " .$post_Month"<br>";

    $Day_Time explode("T"$post_parts[2] );
    print_r$Day_Time ); 
    How do you want to slice up this info, this will show just a little of how to slice and dice this up.

    PHP Code:
    $paragraphs explode"<br><br><br><br>"$blog_text ); 
    Is there a new line character in there "\n" ?
    Computers and Fire ...
    In the hands of the inexperienced or uneducated,
    the results can be disastrous.
    While the professional can tame, master even conquer.

  7. #7
    SitePoint Zealot
    Join Date
    Jun 2006
    Posts
    177
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm perfectly capable of doing string functions, but my questions were this:

    1) How does the data handling function (so not the tag-starting or -stopping ones) know which tag is being handled? Its setup doesn't allow it to be passed on as parameter.
    2) How do I get the data from last entry only?


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
  •