TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 09-15-2009, 04:31 PM   #1 (permalink)
The Contributor
 
russellharrower's Avatar
 
Join Date: Jul 2009
Posts: 80
Thanks: 13
russellharrower is on a distinguished road
Default serialize XML Category

I have been working on this for around 2 days now, Having the same issue it seems that I can serialize the categories.

They return the following
Code:
Array ( [0] => SimpleXMLElement Object ( ) ) a:1:{i:0;O:16:"SimpleXMLElement":0:{}}
Does any one now how to fix this issue?

PHP Code:
<?php
  $feed 
file_get_contents("http://www.techau.tv/blog/?feed=rss2");
  
$xml = new SimpleXmlElement($feed);
  foreach (
$xml->channel->item as $entry)
  {
    echo 
$entry->title.'<br/>';
    echo 
$entry->description.'<br/><br/>';
    
    
$keywordsArray = array();
    foreach (
$entry->category as $a => $b)
    {
      
$keywordsArray[] = $b;
    }
    
print_r($keywordsArray);
    
//serialize keyword array ready for posting in link
    
$keywords str_replace(
      array(
'O:16:"SimpleXMLElement":0:{}''O:16:"SimpleXMLElement":'),
      array(
's:0:"";''O:8:"stdClass":'),
      
serialize($keywordsArray)
      );    
    print 
$keywords;
    print 
"<br/><br/>";
  }
?>
russellharrower is offline  
Reply With Quote
Old 09-15-2009, 08:50 PM   #2 (permalink)
The Addict
 
Join Date: May 2009
Posts: 287
Thanks: 5
adamdecaf is on a distinguished road
Default

PHP Code:

$file 
simplexml_load_file('http://www.techau.tv/blog/?feed=rss2');

print_r($file); 
Done.
__________________
My Site
adamdecaf is offline  
Reply With Quote
Old 09-16-2009, 01:57 AM   #3 (permalink)
how quixotic are you?
 
ETbyrne's Avatar
 
Join Date: Dec 2007
Location: Lapeer, MI
Posts: 445
Thanks: 37
ETbyrne is on a distinguished road
Default

For simple XML adamdecaf's solution should work just fine. However, if you plan on parsing loosely-typed XML (like HTML) and you don't want to mangle the data then you will have to use the DOMDocument class to manually parse the XML.

I wrote a class for Dingo that safely serializes and de-serializes loosely-typed XML by using the DOMDocument class, but you won't be able to get your hands on that until Oct 1.
__________________
Dingo Web Systems > http://www.dingocode.com
My Website > http://www.evanbot.com
ETbyrne is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Categories and sub categories - recursion Dinky Advanced PHP Programming 2 02-01-2010 07:45 PM
SEO Friendly URL, Fetched from Databse Category Id etc.. woowoo Absolute Beginners 1 07-26-2009 03:07 AM
MySQL Category Problem codyodell MySQL & Databases 4 06-07-2008 08:47 PM
Category and order Jonnee Absolute Beginners 6 12-23-2007 09:58 PM
Category System Tutorial Gurnk Tips & Tricks 14 12-10-2007 05:24 AM


All times are GMT. The time now is 12:41 PM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design