Easily Remove /r and /n Chars From MultiLine Literal XML String

protected string CreateInfoRequestPackage()
    {

        string RequestPackage = "<inforequest ID=\"90210\">";
        RequestPackage += @"       
       <UserData>
      <salutation>Mr.</salutation> 
      <fname>John</fname> 
      <lname>Doe</lname> 
      <title>Sr Manager</title> 
      <institution>Acme Inc</institution> 
      <addr1>100 Main St</addr1> 
      <addr2>Suite 12</addr2> 
      <city>Anytown</city> 
      <state>MA</state> 
      <zip>02110</zip> 
      <country>USA</country> 
      <telephone>617-603-7000</telephone> 
      <fax>617-603-7001</fax> 
      <email>test@test.com</email> 
      <investor_type>2</investor_type> 
      <carrier>FEX*PO</carrier> 
      <shipment_account>12345531</shipment_account> 
      <comment>Send ASAP</comment> 
      </UserData>
     <Materials>
     <Material>
      <material_id>3434222</material_id> 
      <qty>1</qty> 
      </Material>
     <Material>
      <material_id>2342344</material_id> 
      <qty>1</qty> 
      </Material>
      </Materials>
      </inforequest>";



        // Using the data above create well formed XML (removing the /r /n)
        XmlDocument xmlDoc = new XmlDocument();
        xmlDoc.LoadXml(RequestPackage);
        return xmlDoc.InnerXml;


        

    }
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s