Jump to content

base64_encode Problem in xml


jeeva

Recommended Posts

Hi frnds,

 

i have a problem with base64_encode

 

i'm using base64_encode function in xml like

 

$content="some word document content here";
$xml="<content><![CDATA[".base64_encode($content)."]]></content>";

 

here its working fine.. the problem is while retrieving the content from xml 

$xmlcont="word document content here after removed xml tag";
echo $con=base64_decode($xmlcont);

 

its giving some junk character.

 

Please help what's wrong with this code?

please give me some other solution if you have faced anything like this.

 

Thanks

Jeeva

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/185200-base64_encode-problem-in-xml/
Share on other sites

Your example is confusing me a little bit...

 

My first assumption is that you might be using XML improperly, or trying to base64_decode the xml tags along in the string.

 

My suggesion would be base64 encode it before it goes into your XML tag, and echo those results.  Then compare those results to what you have after parsing (before you try and decode) and see if they are the same.  Willing to be they aren't :)

 

Can you post more of the example? 

thanks nafetski,

 

Let me explain,

i'm doing some sever and client side script using SOAP.

So i need to pass the value from server to client.

 

First i'm converting word document and stored in a variable.

then i will encrypt the content using base64_encode and assign the value in xml. have a look at example below

Server Side:

$wordcontent="document content...";
$encryptcont=base64_encrypt($wordcontent);

$xml="<?xml encoding="ISO-8859-1"?> .....";
$xml.="<content><![CDATA[".$encryptcont."]]></content>";

And then,

I will parse the xml in to php array

Client Side:

$ResArr=parsexml($xml);
$content=base64_decode($ResArr[content]);

Here is the problem, here i'm not getting the proper content..i'm getting some junk character...

 

Hope you understood.

 

 

Thanks

Jeeva

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.