SitePoint Sponsor |
|
User Tag List
Results 1 to 7 of 7
Thread: Handling data in XML parser
-
Jun 4, 2007, 05:18 #1
- 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
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.
-
Jun 5, 2007, 05:00 #2
- Join Date
- Jun 2006
- Posts
- 177
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Anybody got any ideas?
-
Jun 5, 2007, 11:11 #3
- Join Date
- Jun 2006
- Posts
- 177
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Anybody?
-
Jun 5, 2007, 12:18 #4
- 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.
-
Jun 5, 2007, 13:07 #5
- 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.
-
Jun 5, 2007, 13:49 #6
- 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], 0, strlen( $post_parts[0]-4 ));
print_r( $post_ID );
echo "<br>";
$post_Year = substr( $post_parts[0], -4 );
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 );
PHP Code:$paragraphs = explode( "<br><br><br><br>", $blog_text );
Computers and Fire ...
In the hands of the inexperienced or uneducated,
the results can be disastrous.
While the professional can tame, master even conquer.
-
Jun 5, 2007, 14:11 #7
- 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