ZURINET
asked on
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 DOC
<?xml version="1.0" encoding='UTF-8'?>
<painting>
<caption>
<Price>1511512</Price>
</caption>
</painting>
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 DOC
<?xml version="1.0" encoding='UTF-8'?>
<painting>
<caption>
<Price>1511512</Price>
</caption>
</painting>
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
And for LineFeed
You can use Chr() function to generate line feed Chr(10)
You can use Chr() function to generate line feed Chr(10)
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
It should be
char b = (char) 10;
and just append b into your string
ASKER
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?
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?
ASKER
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
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())
{
//Console.WriteLine(reader.Value);
//start switch
while(reader.NodeType != XmlNodeType.EndElement && reader.Name == "PriceUpdateArtLine")
{
reader.Read();
if (reader.NodeType == XmlNodeType.Text)
{
Console.WriteLine(reader.Value);
string extractBaseString = reader.Value;
priceItems.Add(reader.Value);
//IExporter exporter = new DelimiterExport(data, tw, "\t");
}
}// end switch
}
//priceItems.Add(
Console.ReadLine();
Console.WriteLine(priceItems);
string line = string.Join("", priceItems.ToArray());
Console.WriteLine(line);
StreamWriter mywriter = new StreamWriter("C:\\reminders.txt");
mywriter.Write(line);
mywriter.Close();
Console.ReadLine();
}
Try this.
char CR = (char) 13;
char LF = (char) 10;
string CRLFLF = CR + LF + LF;
char CR = (char) 13;
char LF = (char) 10;
string CRLFLF = CR + LF + LF;
Try this as well
public static string CrLfLf = "\r\n\n";
public static string CrLfLf = "\r\n\n";
Oh by the way after you have your CrLfLf value, you can just concatenate it in your string
yourstring = yourstring + CrLfLf;
yourstring = yourstring + CrLfLf;
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Well, it is up to you if you don't give out points. Anyway, now I know who you are......
Goodluck with your projects! :-)
Goodluck with your projects! :-)
ASKER
Hi Alfred1
<<Anyway, now I know who you are......>> is it with reference to Microsoft forum or?
Have we meet before?
Best Regards
ZH
<<Anyway, now I know who you are......>> is it with reference to Microsoft forum or?
Have we meet before?
Best Regards
ZH
https://www.experts-exchange.com/questions/10239370/Convert-a-String-to-Ascii-code.html?sfQueryTermInfo=1+ascii+code+convert