[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 230
  • Last Modified:

How to get my xml in quoutes

I have code that  creates a xml file.  Why doesnt the information getting written within quotes, and how can I get this accomplished.  Here is the code below and here is what my statment looks like.  This is what I get

<Payment><PropID>WG</PropID><BldgID>WG</BldgID><UnitID>1903003</UnitID><ResiID>7</ResiID><ClientMerchantID>299477748884</ClientMerchantID><ClientTransactionID>18982882</ClientTransactionID><ClientTransactionDate>4/20/2009 11:12:34 PM</ClientTransactionDate><Amount>606.2</Amount><Description>The Apartment Gallery on line payment</Description><ClientJnlNo>0</ClientJnlNo></Payment>
 
THIS IS WHAT I NEED

'<Payments><Payment PropertyID='JP' BldgID='4300' UnitID='5' ResiID='3' ClientMerchantID='257717' ClientTransactionID='11923' ClientTransactionDate='04/01/2009 18:04:53' Amount='885' Description='Web PSID 11923 - ACH' ClientJnlNo=''></Payment></Payments>'
 

 

 

Try
            strPath = HttpRuntime.AppDomainAppPath
            ds.Tables.Add(dt)
            dt.Columns.Add("PropID")
            dt.Columns.Add("BldgID")
            dt.Columns.Add("UnitID")
            dt.Columns.Add("ResiID")
            dt.Columns.Add("ClientMerchantID")
            dt.Columns.Add("ClientTransactionID")
            dt.Columns.Add("ClientTransactionDate")
            dt.Columns.Add("Amount")
            dt.Columns.Add("Description")
            dt.Columns.Add("ClientJnlNo")
 
            r = dt.NewRow
            With dt
                r(0) = Session("vPropID").ToString
                r(1) = Session("vBldgID").ToString
                r(2) = Session("vUnitID").ToString
                r(3) = Session("vResiID").ToString
                r(4) = "299477748884"
                r(5) = "18982882"
                r(6) = Now.ToString
                r(7) = txtTotalCharge.Text
                r(8) = usaepay.Description
                r(9) = "0"
            End With
 
            dt.Rows.Add(r)
            Dim strXML As String = ""
 
            ds.WriteXml(MS, XmlWriteMode.IgnoreSchema)
            ds.WriteXml(strPath + "/" + "AddPayment.xml", XmlWriteMode.IgnoreSchema)
            MS.Position = 0
 
            'to get the XML as a string we need to use a streamreader
 
            strXML = SR.ReadToEnd()    'now the string of the XML is stored in strXML
            x.LoadXml(myLedger.AddPayment("AptGallery", "apts", "Production", 1, strXML))
 
            Dim dsNew As New DataSet
 
            dsNew.ReadXml(New XmlTextReader(New StringReader(x.InnerXml)))
        Catch ex As Exception
            MsgBox(ex.Message)
            'GetOpenItems = New DataSet
        End Try

Open in new window

0
mgmhicks
Asked:
mgmhicks
1 Solution
 
Sreedhar VengalaCommented:
Try with this: Output as in attached screenshot
using System.Data;
using System.Xml;
 
namespace EE_Engine
{
    internal class Program
    {
        private static void Main(string[] args)
        {
            var objDOM = new XmlDocument();
            XmlElement objRoot = objDOM.CreateElement("results");
            XmlElement objElem = default(XmlElement);
            int lngPos = 0;
 
 
            var dt = new DataTable("MyTable");
 
            dt.Columns.Add("PropertyID");
            dt.Columns.Add("BldgID");
            dt.Columns.Add("UnitID");
            dt.Columns.Add("ResiID");
            dt.Columns.Add("ClientTransactionID");
            dt.Columns.Add("ClientTransactionDate");
            dt.Columns.Add("Amount");
            dt.Columns.Add("Description");
            dt.Columns.Add("ClientJnlNo");
 
            DataRow dr = dt.NewRow();
            dr["PropertyID"] = "JP";
            dr["BldgID"] = "4300";
            dr["UnitID"] = "5";
            dr["ResiID"] = "3";
            dr["ResiID"] = "257717";
            dr["ClientTransactionID"] = "11923";
            dr["ClientTransactionDate"] = "04/01/2009 18:04:53";
            dr["Amount"] = "885";
            dr["Description"] = "Web PSID 11923 - ACH";
            dr["ClientJnlNo"] = " ";
 
            dt.Rows.Add(dr);
 
 
            foreach (DataRow objRow in dt.Rows)
            {
                objElem = objDOM.CreateElement("Payment");
                foreach (DataColumn column in dt.Columns)
                {
                    objElem.SetAttribute(column.ColumnName, objRow[column.ColumnName].ToString());
                }
            }
 
            objRoot.AppendChild(objElem);
        }
    }
}

Open in new window

output.jpg
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now