Home  |  Linux  | Mysql  | PHP  | XML
From:Chris W Date:Fri May  9 13:50:40 2008
Subject:xml processing cdata
I have an xml file with a cdata element like the one below.  How would I 
use the php xml functions to extract that cdata and save it as a pdf file?

<attach id="2" display-name="207069.pdf" file-name="207069.pdf" 
obj-type="1" system="0">
  <![CDATA[eJysumVQW1/0NtoWK95CcXe3EFxK8QDBCQ5 ...... ]]>
 </attach>



The code I have is this...

$in = fopen("test.xml", 'r');
$XMLStr = '';
while (!feof($in)) {
  $LineNumber++;
  $XMLStr .= fgets($in);
}
$XML = simplexml_load_string($XMLStr);
foreach($XML->props->attachments->attach as $Attachment){
  print_r($Attachment);
}
The output looks like this...

SimpleXMLElement Object
(
    [@attributes] => Array
        (
            [id] => 2
            [display-name] => 207069.pdf
            [file-name] => 207069.pdf
            [obj-type] => 1
            [system] => 0
        )

)


-- 
Chris W
KE5GIX

"Protect your digital freedom and privacy, eliminate DRM, 
learn more at http://www.defectivebydesign.org/what_is_drm"

Ham Radio Repeater Database.
http://hrrdb.com

Navigate in group php.general at sever news.php.net
Previous Next




  
© No Copyright
You are free to use Anything
Site Maintained by PHP Developer
Powered By PHP Consultants