Note that there are some explanatory texts on larger screens.

plurals
  1. POHow do I Insert a Local String Variable into a TextWriter Writeline Method without it causing a line break?
    primarykey
    data
    text
    <p>I am attempting to insert a parsed XML element into the middle of a TextWriter WriteLine without it causing a line break where the variable is added, but am having no success. The purpose of the program is to transform an XML file into a .txt file in X12 850 EDI format, and I need to preserve the lines as dictated by the WriteLine methods. I am not certain this is the most efficient way to make the translation, as I am only one week into my C# career, but my other attempts using xslt files have proven inefficient. Any guidance would be greatly appreciated. Below is the code for my translator.</p> <pre><code>class Class1 { public static void Main() { StringBuilder name = new StringBuilder(); String xmlString = ("3.xml"); using (XmlReader reader = XmlReader.Create(new StreamReader(xmlString))) { reader.ReadToFollowing("Name"); name.AppendLine(reader.ReadElementContentAsString()); } using (StreamWriter sw = new StreamWriter("test5.txt")) { sw.WriteLine("ISA*00* *00* *ZZ*daisywebstore *12*5016361200 *11213*1022*U*00400*000001649*0*P*&gt;~"); sw.WriteLine("GS*PO*9254291001*5016361200*20111213*1022*1649*X*004010~"); sw.WriteLine("ST*850*0001~"); sw.WriteLine("BEG*00*SA*08272225944**20111213~"); sw.WriteLine("REF*DP*089~"); sw.WriteLine("DTM*002*20120104~"); sw.WriteLine("N1*ST*" + name + "~"); sw.WriteLine("N3*1400 S MC CARREN BLVD~"); sw.WriteLine("SN4*SPARKS*NV*894316301~"); sw.WriteLine("N1*RE**92*00103653341~"); sw.WriteLine("PO1*1*6*EA*33.28*TE*IN*081643211*UP*30039256056937~"); sw.WriteLine("PID*F****CO2 BB PISTOL $ 5693~"); sw.WriteLine("PO4*3*1*EA~"); sw.WriteLine("CTT*1~"); sw.WriteLine("AMT*1*199.68~"); sw.WriteLine("SE*16*0001~"); } } } </code></pre> <p>}</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload