C# question – xmlDoc.Write – preserving line breaks?

Home Page Forums BizTalk 2004 – BizTalk 2010 C# question – xmlDoc.Write – preserving line breaks?

Viewing 1 reply thread
  • Author
    Posts
    • #20611

      Is there anyway to get xmlDoc.Write to put the line breaks between the elements?
      I’m getting a godo output file, but it’s not formatted, which makes doing a side-by-side compare very difficult.

      Partial sample code below to show what I’m doing (writing a test data generator to copy one xml file, change the loan number, and write out 100 or 1000 other files).

      Thanks
      Neal Walters   

       

       

       

       

       

       

       

      XmlDocument xmlDocNew = new XmlDocument

      ();

      xmlDocNew.LoadXml(strNewXML);

       

       

      string strOutputFileName = strOutputDirName + “Loan_” + longCurrentLoanNumber.ToString() + “.xml”

      ;

       

       

      XmlWriter xtw = new XmlTextWriter(strOutputFileName,System.Text.Encoding

      .ASCII);  // I’ve tried a few different encodings here

       

       

      //xmlDocNew.WriteContentTo(xtw);

       

      xmlDocNew.WriteTo(xtw);

      xtw.Close();

    • #20612

      Hi Neal,

      It sounds like you just want to apply a nice pretty formatting (line breaks, indentions) to an XML document?  If so, all you need to do is open the XML file in Visual Studio, and select Edit -> Advanced -> Format Document.  If you want a more lightweight XML editor, you should try Notepad++:  http://notepad-plus.sourceforge.net/uk/site.htm.  You need to download the editor and the XML Tools plugin.  Once you install the XML tools plugin, you can apply XML formatting just like you can in Visual Studio:  Just open the XML file, then select Plugins -> XML Tools -> Pretty Print (XML only – with line breaks).

Viewing 1 reply thread
  • The forum ‘BizTalk 2004 – BizTalk 2010’ is closed to new topics and replies.