0

From which PHP 5 version does simplexml_load_file support CDATA?

 $xml = @simplexml_load_file($url, NULL, LIBXML_NOCDATA);

Thanks!!

3
  • You're contradicting yourself a little here; you want CDATA support, yet you've set the LIBXML_NOCDATA flag? Commented Sep 6, 2011 at 19:44
  • 1
    i believe the LIBXML_NOCDATA prevents the cdata from being escaped and left out of the object. see: us3.php.net/manual/en/function.simplexml-load-file.php#85484 Commented Sep 6, 2011 at 19:47
  • The CDATA is not "left out of the object", it is just not visible in var_dump, print_r, etc, causing confusion. There is no need to pass LIBXML_NOCDATA in order to work with SimpleXML in the normal way; for an explanation of what it actually does, see stackoverflow.com/a/13981917/157957 Commented May 30, 2013 at 17:31

3 Answers 3

3

I'm not entirely sure this answers your question (some clarity might help?) but I found this at php.net:

https://www.php.net/manual/en/function.simplexml-load-file.php#82067

"A PHP version >= 5.1.0 is required for this to work"

Sign up to request clarification or add additional context in comments.

3 Comments

Does it also support CDATA from that version?
the only thing that is clear to me is that 5.1 is required to include the CDATA in the object. I'm not sure what happens when using php < 5.1.
PHP 5.1 is required to support the LIBXML_NOCDATA option; it is not required to include the CDATA in the object, becase the CDATA is always there - it's just not visible in var_dump, print_r, etc
1

As in http://php.net/manual/en/function.simplexml-load-file.php said, I think from PHP version >= 5.1.0

Comments

0

SimpleXML supports CDATA in any version, and there is no need to pass LIBXML_NOCDATA. See https://stackoverflow.com/a/13830559/157957 and https://stackoverflow.com/a/16842431/157957

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.