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

  • SEARCH
  • Home
  • 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 6979047
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T17:50:08+00:00 2026-05-27T17:50:08+00:00

I am attempting to insert a parsed XML element into the middle of a

  • 0

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.

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*>~");
            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~");
        }
    }
}

}

  • 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-27T17:50:09+00:00Added an answer on May 27, 2026 at 5:50 pm

    You are doing

    name.AppendLine(reader.ReadElementContentAsString())
    

    Which you shouldexpect to add a new line. Maybe try just

    name.Append(reader.ReadElementContentAsString()) 
    

    instead?

    EDIT:
    Though it seems to be unnecessary for name to be a stringbuilder at all. Maybe just make it a string?

    In which case you could just do

    name = reader.ReadElementContentAsString()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm attempting to parse an XML file, and generate & insert the element data
I am attempting to insert a custom behavior into my service client, following the
I am attempting to insert data into a local SQLITE database file from a
I am attempting to insert an image into a rich text file. I have
I'm attempting to do something like the following: INSERT INTO `File` (`Name`, `Owner`) SELECT
I am attempting to insert data into a table that contains a lot of
I'm attempting to insert some integers into a Postgres table with the following somewhat
I'm attempting to insert an array into a SQL Server database. 1/4 is copied
I am attempting to insert text from a database into a custom TextArea component,
I am attempting to insert a mass of records into SQL Server 2005 from

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.