473,382 Members | 1,424 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Convert XML file data to byte array by FromBase64String passing(string xmlData)

1
I've a xml file.I'm taking its data passing it to a method in string form and converting that string "xmlData" to a array of bytes by Convert.FromBase64String(xmlData) but I'm getting a exception "Invalid character in Base-64 string."

My code is like this.

XmlTextReader xmlReader = new XmlTextReader(XML_LAYOUT_FILE_PATH);
XmlDocument doc = new XmlDocument();
doc.Load(xmlReader);
StringWriter writer = new StringWriter();
XmlTextWriter xmlWriter = new XmlTextWriter(writer);
doc.WriteTo(xmlWriter);

string xmlData = writer.ToString();

byte[] userSettings = Convert.FromBase64String(xmlData);---------Exception is thrown here.

Here XML_LAYOUT_FILE_PATH is the xml file location.

So anybody can suggest some solution as to why this exception is coming and what is the solution to it.

My xml file is like this.

<SOAP-ENV:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:clr="http://schemas.microsoft.com/soap/encoding/clr/1.0" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Body>
------------------------
------------------------
Content of file
-----------------------
----------------------
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>


Does this <SOAP-ENV--------> tag is the problem?
Jan 30 '08 #1
0 7061

Sign in to post your reply or Sign up for a free account.

Similar topics

10
by: Jochen Hub | last post by:
Hi, I am a real beginner in Python and I was wondering if there is a way to convert a string (which contains a list) to a "real" list. I need this since I would like to give a list as an...
2
by: Nathan | last post by:
Is there a way to convert a string to a CipherMessage? I am calling a function that decrypts a CipherMessage and returns the value. The only problem is when I want to use an encrypted value stored...
6
by: tvn007 | last post by:
Hi, I tried to convert string data type to char type so that I can use strtok. I have used c_str(). However, still getting error message when compile . Any help would be appreciate.
8
by: FrzzMan | last post by:
How to convert back a string that have converted to byte using System.Text.Encoding.UTF8.GetBytes() string StringData = "This is a string"; byte ConvertedString =...
5
by: XML newbie: Urgent pls help! | last post by:
function to convert string to 1 dimensional array of long in VB.Net
3
by: Ursula | last post by:
Is it possible to convert a string in a file. The problem is this: I have an object string that is a file xml and I want to pass to Deserialize function, but Deserialize function expect an object...
5
by: 9966 | last post by:
Hi, currently I'm having a problem on converting a string type array into a char type. An example is as follows: string fruits; vector <char> temp; The fruits array HAS to be a string type and...
4
by: Man4ish | last post by:
HI , I am trying to convert string into char array of characters.but facing problem. #include <iostream> #include <string> using namespace std; int main() { string t="1,2,3,4,5,6";
12
by: Peter | last post by:
Trying to convert string to byte array. the following code returns byte array of {107, 62, 194, 139, 64} how can I convert this string to a byte array of {107, 62, 139, 65} ...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.