PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > php.general > xml processing cdata
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
xml processing cdata

Réponse
 
LinkBack Outils de la discussion
Vieux 09/05/2008, 21h50   #1
Chris W
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut 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

  Réponse avec citation
Vieux 10/05/2008, 05h51   #2
Brady Mitchell
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: [PHP] xml processing cdata

The last comment on http://php.net/manual/en/function.si...oad-string.php
is what you need:

simplexml_load_string($xmlstring, 'SimpleXMLElement', LIBXML_NOCDATA);

Brady


On May 9, 2008, at 1250PM, Chris W wrote:

> 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
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>


  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 21h03.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,12805 seconds with 10 queries