Slight tweak in (short) code neeeded

Discussion in 'PHP' started by snigster, Mar 24, 2009.

  1. #1
    Hi,

    I've been using this PHP code to retrieve external RSS feeds.

    
    
    $doc = new DOMDocument();
    $doc->load($feedurl);
    $arrFeeds = array();
    foreach ($doc->getElementsByTagName('item') as $node) {
    	$itemRSS = array ( 
    		'title' => $node->getElementsByTagName('title')->item(0)->nodeValue,
    		'desc' => $node->getElementsByTagName('description')->item(0)->nodeValue,
    		'link' => $node->getElementsByTagName('link')->item(0)->nodeValue,
    		'date' => $node->getElementsByTagName('pubDate')->item(0)->nodeValue
    		);
    	array_push($arrFeeds, $itemRSS);
    }
    
    
    
    Code (markup):
    Rather than load an external xml file, I want to load some xml stored in variable $xml but I can't get it to work.

    Could anyone show me the way?? It will be much appreciated, my head is starting to hurt.
     
    snigster, Mar 24, 2009 IP
  2. centralb

    centralb Peon

    Messages:
    26
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Use DOMDocument::loadXML instead of DOMDocument::load


    try changing
    to

     
    centralb, Mar 24, 2009 IP
    snigster likes this.
  3. snigster

    snigster Peon

    Messages:
    88
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thanks!

    I'm embarrassed how long I've spent on this and simple it was to acheive.

    You are a beautiful man!
     
    snigster, Mar 24, 2009 IP