Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7489519
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T15:15:41+00:00 2026-05-29T15:15:41+00:00

I’ve ready many posts (such as this one) on SO now which explain how

  • 0

I’ve ready many posts (such as this one) on SO now which explain how to write binary data to an XML using the XMLWriter.WriteBase64 method. However, I’ve yet to see one which explains how to then read the base64’d data. Is there another built in method? I’m also having a hard time finding solid documentation on the subject.

Here is the XML file that I’m using:

<?xml version="1.0"?>
<pstartdata>
  <pdata>some data here</pdata>
  emRyWVZMdFlRR0FFQUNoYUwzK2dRUGlBS1ZDTXdIREF ..... and much, much more.
</pstartdata>

The C# code which creates that file (.Net 4.0):

FileStream fs = new FileStream(Path.GetTempPath() + "file.xml", FileMode.Create);

            System.Xml.XmlTextWriter w = new System.Xml.XmlTextWriter(fs, null);
            w.Formatting = System.Xml.Formatting.None;

            w.WriteStartDocument();
            w.WriteStartElement("pstartdata");
            #region Main Data
            w.WriteElementString("pdata", "some data here");

            // Write the binary data
            w.WriteBase64(fileData[1], 0, fileData[1].Length);
            #endregion (End) Main Data (End)

            w.WriteEndDocument();
            w.Flush();
            fs.Close();

Now, for the real challenge…
Alright, so as you all can see the above was written in .Net 4.0. Unfortunately, the XML file needs to be read by an application using .Net 2.0. Reading in the binary (base 64) data has proven to be quite the challenge.

Code to read in XML data (.Net 2.0):

System.Xml.XmlDocument xDoc = new System.Xml.XmlDocument();

            xDoc.LoadXml(xml_data);

            foreach (System.Xml.XmlNode node in xDoc.SelectNodes("pstartdata"))
            {
                foreach (System.Xml.XmlNode child in node.ChildNodes)
                {
                    MessageBox.Show(child.InnerXml);
                }
            }

What would I need to add in order to read in the base 64’d data (shown above)?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T15:15:43+00:00Added an answer on May 29, 2026 at 3:15 pm

    You seem to write some bad XML – use the following to write the data:

            w.WriteStartDocument();
            w.WriteStartElement("pstartdata");
            #region Main Data
            w.WriteElementString("pdata", "some data here");
    
            // Write the binary data
            w.WriteStartElement("bindata");
            w.WriteBase64(fileData[1], 0, fileData[1].Length);
            w.WriteEndElement();
            #endregion (End) Main Data (End)
    
            w.WriteEndDocument();
            w.Flush();
            fs.Close();
    

    For reading you will have to use XmlReader.ReadContentAsBase64.

    As you have asked for other methods to write and read binary data – there are XmlTextWriter.WriteBinHex and XmlReader.ReadContentAsBinHex. BEWARE that these produce longer data than their Base64 pendants…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am reading a book about Javascript and jQuery and using one of the
this is what i have right now Drawing an RSS feed into the php,
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We are using XSLT to translate a RIXML file to XML. Our RIXML contains
I'm making a simple page using Google Maps API 3. My first. One marker
I have some data like this: 1 2 3 4 5 9 2 6
I have a jquery bug and I've been looking for hours now, I can't
I used javascript for loading a picture on my website depending on which small
link Im having trouble converting the html entites into html characters, (&# 8217;) i

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.