Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7922573
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T17:00:40+00:00 2026-06-03T17:00:40+00:00

I have this strange problem parsing XML document in PHP loaded via cURL. I

  • 0

I have this strange problem parsing XML document in PHP loaded via cURL. I cannot get nodeValue containing URL address (I’m trying to implement simple RSS reader into my CMS). Strange thing is that it works for every node except that containing url addresses and date ( and ).

Here is the code (I know it is a stupid solution, but I’m kinda newbie in working with DOM and parsing XML documents).

function file_get_contents_curl($url) {

$ch = curl_init();    // initialize curl handle
curl_setopt($ch, CURLOPT_URL, $url); // set url to post to
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // return into a variable
curl_setopt($ch, CURLOPT_TIMEOUT, 4); // times out after 4s
$result = curl_exec($ch); // run the whole process

return $result;
}

function vypis($adresa) {

$html = file_get_contents_curl($adresa);

$doc = new DOMDocument();
@$doc->loadHTML($html);

$nodes = $doc->getElementsByTagName('title');
$desc = $doc->getElementsByTagName('description');
$ctg = $doc->getElementsByTagName('category');
$pd = $doc->getElementsByTagName('pubDate');
$ab = $doc->getElementsByTagName('link');
$aut = $doc->getElementsByTagName('author');


for ($i = 1; $i < $desc->length; $i++) {

    $dsc = $desc->item($i);
    $titles = $nodes->item($i);
    $categorys = $ctg->item($i);
    $pubDates = $pd->item($i);
    $links = $ab->item($i);
    $autors = $aut->item($i);

    $description = $dsc->nodeValue;
    $title = $titles->nodeValue;
    $category = $categorys->nodeValue;
    $pubDate = $pubDates->nodeValue;
    $link = $links->nodeValue;
    $autor = $autors->nodeValue;

    echo 'Title:' . $title . '<br/>';
    echo 'Description:' . $description . '<br/>';
    echo 'Category:' . $category . '<br/>';
    echo 'Datum ' . gmdate("D, d M Y H:i:s",
       strtotime($pubDate)) . " GMT" . '<br/>';
    echo "Autor: $autor" . '<br/>';
    echo 'Link: ' . $link . '<br/><br/>';
}
}

Can you please help me with this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T17:00:43+00:00Added an answer on June 3, 2026 at 5:00 pm

    To read RSS you shouldn’t use loadHTML, but loadXML. One reason why your links don’t show is because the <link> tag in HTML ignores its contents. See also here: http://www.w3.org/TR/html401/struct/links.html#h-12.3

    Also, I find it easier to just iterate over the <item> tags and then iterate over their children nodes. Like so:

    $d = new DOMDocument;
    // don't show xml warnings
    libxml_use_internal_errors(true);
    $d->loadXML($xml_contents);
    // clear xml warnings buffer
    libxml_clear_errors();
    
    $items = array();
    
    // iterate all item tags
    foreach ($d->getElementsByTagName('item') as $item) {
        $item_attributes = array();
        // iterate over children
        foreach ($item->childNodes as $child) {
            $item_attributes[$child->nodeName] = $child->nodeValue;
        }
        $items[] = $item_attributes;
    }
    
    var_dump($items);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have this strange problem with the PHP function CTYPE_ALNUM if i do: PHP:
Starting from Android 3.2 I have this strange problem. It's very easy to reproduce:
I have a problem with a strange crash on iPad 5.0. This crash only
I just noticed something strange. If I have this XML: <level number=7 background=background_5> and
I have this strange problem in my unit tests. See the following code _pos
I have this very strange problem while compiling the project. MOC seems to be
I have a very strange problem with facebook OG. https://fit.upjet.com/en/pages/news/270/ - this is a
I've got this strange problem using py-amqp and the Flopsy module. I have written
I have this really strange problem where my entity framework query isn't enumerating correctly.
I am having a strange problem when using this XML-to-NSDictionary class.really it was working

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.