How can I get the CData of this tag, it shows like this in XML

<Name><![CDATA[John & Mary]]></Name>

This does not work when I include the names in CData

$Staff= new SimpleXMLElement("details.php?staff=$ID", null, true);
foreach($Staff as $Person){
?>

<?php 
$Name = $Person->Name;
echo $Name;

    Well for one, this:

    SimpleXMLElement("details.php?staff=$ID", null, true); 

    makes no sense at all. The SimpleXMLElement::__construct() method (manual page: [man]simplexmlelement.construct[/man]) lists the parameters the method expects. None of the three values you're providing in your code make sense with their corresponding description in the manual.

      what I don't see the problem

      data is my url
      options is null
      data_is_url is true

      The code works fine. What is the issue?

        'details.php?staff=$ID' is not a URL. URLs begin with a scheme name followed by two colons and two forward slashes, such as 'http://'.

          Sorry I've removed my http:// as the link can not be shared :-)

            obfuscating code (e.g., replacing the actual URL with something like [font=monospace]http://www.example.com/details.php?staff=$ID[/font]) would be less confusing.

            Additionally, "security by obscurity" is not a good idea. If the URL in question provides sensitive information, then keeping the exact URL "secret" should not be your only safeguard. (Shouldn't even be one of your safeguards.)

            As for your CDATA problem, you might read this.

              Thanks, can we please look at the original question now?

                NZ_Kiwis;11000559 wrote:

                Thanks, can we please look at the original question now?

                traq;11000539 wrote:

                As for your CDATA problem, you might read this.

                did you try this out?

                  One of the PHP.net pages (sorry - I was browsing last night and I don't remember exactly where I saw it) had comments regarding CDATA being stored separately from the actual element, and reading involving casting to strings ...

                  I'll see if I can find it again. Just Google the hell out of 'PHP simplexml cdata', that's how I found it in the first place.

                    Write a Reply...