Process XML document to Ascii

Hi all
I have need to read an xml element, and convert the result to ASCII.

Need to write the element price in ASCII file, with character line feed at the end of line


<?xml version="1.0" encoding='UTF-8'?>

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Alfred A.Commented:
Alfred A.Commented:
Check the following code as well:

System.Text.Encoding ascii = System.Text.Encoding.ASCII;
Byte[] encodedBytes = ascii.GetBytes(str);
foreach (Byte b in encodedBytes)
   // b here is ascii.


foreach (char c in str)
     ascii = (int) c;

Alfred A.Commented:
And for LineFeed

You can use Chr() function to generate line feed Chr(10)
Build an E-Commerce Site with Angular 5

Learn how to build an E-Commerce site with Angular 5, a JavaScript framework used by developers to build web, desktop, and mobile applications.

Alfred A.Commented:
Oh correction on my previous post regarding linefeed, I mixed VB.NET with C#

It should be

char b = (char) 10;

and just append b into your string
ZURINETAuthor Commented:
Hi all
Thanks for the input..

I need to parse the xml first..?
How do I do it.. ?
This seems to be my biggest problem..

How to I store or convert the result of the parse as byte?
ZURINETAuthor Commented:
Hi all

This is what I came up with..

The code works.. but the output is just a string..

I need the output with CRLF
and an extra LF at the end of the file

static void Main(string[] args)

            List<string> priceItems = new List<string>();     // Must not be list .. just need a container      

            System.IO.StreamReader stream = new System.IO.StreamReader("C:\\Prise.xml");
            XmlTextReader reader = null;
            reader = new XmlTextReader(stream);
            while (reader.Read())


                //start switch
              while(reader.NodeType != XmlNodeType.EndElement && reader.Name == "PriceUpdateArtLine")

               if (reader.NodeType == XmlNodeType.Text)
                   string extractBaseString = reader.Value;

                   //IExporter exporter = new DelimiterExport(data, tw, "\t");  
                }// end switch

            string line = string.Join("", priceItems.ToArray());
             StreamWriter mywriter = new StreamWriter("C:\\reminders.txt");

Open in new window

Alfred A.Commented:
Try this.

char CR = (char) 13;
char LF = (char) 10;

string CRLFLF = CR + LF + LF;
Alfred A.Commented:
Try this as well

public static string CrLfLf = "\r\n\n";
Alfred A.Commented:
Oh by the way after you have your CrLfLf value, you can just concatenate it in your string

yourstring = yourstring + CrLfLf;
ZURINETAuthor Commented:
Hi all

Thanks for your help ..

Found what i am looking for ..

Works like Magic..

No points.. given out :-(

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Alfred A.Commented:
Well, it is up to you if you don't give out points.  Anyway, now I know who you are......

Goodluck with your projects!  :-)
ZURINETAuthor Commented:
Hi Alfred1

<<Anyway, now I know who you are......>> is it with reference to Microsoft forum or?
Have we meet before?

Best Regards
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.