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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T21:23:30+00:00 2026-05-25T21:23:30+00:00

Simplexml_load_string is removing a lot of content that is passing into it. var_dump($cleaned); <item>

  • 0

Simplexml_load_string is removing a lot of content that is passing into it.

var_dump($cleaned);
<item>
   <title><![CDATA[Honda Motor Company: Motorcycles to the Civic and Accord]]></title>
   <link>http://www.link.com/index.php?id=9987</link>
   <description><![CDATA[Though this company is famous for its cars, it actually started as a motorcycle manufacturer. http://www.link.com takes a look at the history of the Honda Motor Company, from its popular motorcycles to the Civic and the Accord.]]>    </description>
   <pubDate>Fri, 23 Sep 2011 10:55:50 -0400</pubDate>
   <guid>https://link.cloudfront.net/581575d3053ac1a578065c10f2bac1be.mp4</guid>
   <media:title><![CDATA[Honda Motor Company: Motorcycles to the Civic and Accord]]>    </media:title>
<media:description><![CDATA[Though this company is famous for its cars, it actually started as a motorcycle manufacturer. http://www.link.com takes a look at the history of the Honda Motor Company, from its popular motorcycles to the Civic and the Accord.]]></media:description>

<media:keywords><![CDATA[Honda Motor Company, Honda, motorcycles, Japan, Civic, Accord, Formula 1, F1, Acura, fuel efficiency, hybrid, ASIMO, robot, aviation, Dream D, Isle of Man races, Super Cub, auto, automotive, automobile, automaker, cars, driving, history, Soichiro Honda]]></media:keywords>
<media:tags><![CDATA[Asian History, Automakers, Company Profiles, Honda Motor Company, Honda, motorcycles, Japan, Civic, Accord, Formula 1, F1, Acura, fuel efficiency, hybrid, robot, aviation, auto, automotive, automobile, automaker, cars, driving, history, Soichiro Honda]]></media:tags>
<media:category><![CDATA[/Video/Auto/Reviews and Profiles]]></media:category>
<media:thumbnail url="http://link.cloudfront.net/images/linkthumbs/A-RP-Honda-480i60_100x57.jpg"/>   
<media:content url="https://link.cloudfront.net/581575d3053ac1a578065c10f2bac1be.mp4"  type="video/mp4" >
  <media:thumbnail url="http://link.cloudfront.net/images/linkthumbs/A-RP-Honda-480i60_100x57.jpg"/>
  <media:player url="http://www.link.com/index.php?id=9987"><![CDATA[<embed src="https://link.cloudfront.net/581575d3053ac1a578065c10f2bac1be.mp4" type="application/x-shockwave-flash" wmode="transparent" width="480" height="270"></embed>]]></media:player>
  <media:text_content><![CDATA[Long description.]]></media:text_content>
  <media:filename><![CDATA[]]></media:filename>

  <media:author><![CDATA[Rebecca Brayton]]></media:author>
  <media:bliptv_thumbnail><![CDATA[A-RP-Honda-480i60_480x270.jpg]]></media:bliptv_thumbnail>
  <media:preference_rate><![CDATA[4]]></media:preference_rate>
</media:content>

After running the code below

$xml = simplexml_load_string(utf8_encode($cleaned), 'SimpleXMLElement', LIBXML_NOCDATA);

It returns

["item"]=>
array(100) {
  [0]=>
  object(SimpleXMLElement)#4 (5) {
    ["title"]=>
    string(56) "Honda Motor Company: Motorcycles to the Civic and Accord"
    ["link"]=>
    string(42) "http://www.link.com/index.php?id=9987"
    ["description"]=>
    string(232) "long description."
    ["pubDate"]=>
    string(31) "Fri, 23 Sep 2011 10:55:50 -0400"
    ["guid"]=>
    string(74) "https://link.cloudfront.net/581575d3053ac1a578065c10f2bac1be.mp4"
  }

No other code is being ran before this and I just can’t seem to figure out why on earth this is happening. Anyone know the reason behind this, is it due to the utf-8 encode?

  • 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-25T21:23:30+00:00Added an answer on May 25, 2026 at 9:23 pm

    You need to call SimpleXMLElement->children() with the "media" namespace to get the portions which are of the <media:xxx> kind of format, or pass the $ns argument to simplexml_load_string() to specify the namespace you want to load:

    $xml = simplexml_load_string(utf8_encode($cleaned), 'SimpleXMLElement', LIBXML_NOCDATA, 'media');
    

    http://www.php.net/manual/en/function.simplexml-load-string.php

    http://www.php.net/manual/en/simplexmlelement.children.php

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

Sidebar

Related Questions

I am Parsing XML currently using: $data = simplexml_load_string($xmlFile); foreach($data->item as $key => $current){
Let's say I have some XML like this <channel> <item> <title>This is title 1</title>
I have the following code that converts my twitter account rss feed into a
So I have a PHP file that I use to define all my constants
Using simplexml_load_string() how do I get ForgotPassword from the following XML? <?xml version=1.0 encoding=utf-8?>
When I try to load an HTML file as XML using simplexml_load_string I get
So I run some code like this: $quote = simplexml_load_string($xml); $quote = $quote->Stock; echo
I'm trying to find a xml-interpret function (like the simplexml_load_string) in Python, but with
Well, I do a return simplexml_load_string($data, 'SimpleXMLElement', LIBXML_COMPACT | LIBXML_NOCDATA | LIBXML_NOBLANKS | LIBXML_NOEMPTYTAG
I need to parse XML string into an array. I have XML <group xmlns=123

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.