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 6598909
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T18:25:05+00:00 2026-05-25T18:25:05+00:00

Hello good day I am trying to scrape an xml feed that was given

  • 0

Hello good day I am trying to scrape an xml feed that was given to us, I am using simple htmldom to scrape it but some contents have cdata, how can I remove it?

<date>
<weekday>
<![CDATA[ Friday
]]> 
</weekday>
</date>

php

<?php     
<?php 
include('simple_html_dom.php'); 
include ('phpQuery.php'); 
if (ini_get('allow_url_fopen'))
$xml  = file_get_html('http://www.link.com/url.xml'); }
else{       $ch = curl_init('http://www.link.com/url.xml');
curl_setopt  ($ch, CURLOPT_HEADER, false);        
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);           
$src = curl_exec($ch);           
$xml = str_get_html($src, false);  }   
?>
<?php 
foreach($xml->find('weekday') as $e)
echo $e->innertext  . '<br>';
?>

I believe by default simplehtmldom removes the cdata but for some reason it doesn’t work.

Kindly tell me if you need any info that would be helpful to solve this issue

Thank you so much for your help

  • 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-05-25T18:25:06+00:00Added an answer on May 25, 2026 at 6:25 pm

    You can make use of another xml parser that is able to convert cdata into a string (Demo):

    $innerText = '<![CDATA[ Friday
    ]]>';
    
    $innerText = (string) simplexml_load_string("<x>$innerText</x>"));
    

    Extended code-example based on OP’s code

    # [...]
    <?php 
    foreach($xml->find('weekday') as $e)
    {
        $innerText = $e->innertext;
        $innerText = (string) simplexml_load_string("<x>$innerText</x>");
        echo $innerText . '<br>';
    }
    ?>
    

    Usage instructions: Locate the line which contains the foreach and then compare the original code with the new code (only the foreach in question has been replaced).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to represent the list hi, hello, goodbye, good day, howdy (with that
Hello and good day to you. Situation: For some reason, from time to time
Hello I asked this question to superuser but I did not get a good
So I've spent all day looking for good examples of using xpath / xquery
Hello i am trying to do a dictionary by using Python, What needs to
Hello and good day to all. I have the following code to retrieve from
Hello and good day to you. Is this true (is it required by standard)
Hello and good day to you. Following code fragment compiles on cl.exe (15.00.30729.01) and
Hello and good day to all. I have an issue on coding, i have
Hello and good day to all. I have a little question about like statement

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.