Hello all. I am new to ASP.NET XML so I am looking for some guidance. I have an XML string that needs to read into an ASP.NET C# Gridview. The XML data actually comes from the CRM SDK crm web service (FetchXML). The XML Elements contain (dots) and attributes which seem to be the issue here. If I do a Replace on the XML and remove the DOT, I still cannot read the entire XML string into Gridview because there is an attribute with that element. (notice the ppl.amount)
Here is the XML output that was generated from FetchXML:
<resultset morerecords="0" paging-cookie="<cookie page="1"><productid last="{CA101515-275C-DE11-B856-00237D653ED0}" first="{245798D8-0660-DE11-8B1F-00237D653ED0}" /></cookie>">
<result>
<name>Device with Standard Service for Warranty</name>
<description>Device with Standard Service for Warranty</description>
<productid>{245798D8-0660-DE11-8B1F-00237D653ED0}</productid>
<ppl.transactioncurrencyid name="US Dollar" dsc="0">{C9D286D4-AE18-DE11-8153-00237D653ED0}</ppl.transactioncurrencyid>
<ppl.amount formattedvalue="$0.00">0</ppl.amount>
</result>
<result>
<name>RF Remote</name>
<description>RF Remote</description>
<productid>{BF107F7D-A461-DE11-8B1F-00237D653ED0}</productid>
<ppl.transactioncurrencyid name="US Dollar" dsc="0">{C9D286D4-AE18-DE11-8153-00237D653ED0}</ppl.transactioncurrencyid>
<ppl.amount formattedvalue="$25.00">25</ppl.amount>
</result>
</resultset>
I need some code that would read this XML properly into a dataset that I can assign to the Gridview datasource.
Here is the code I am using now:
DataSet ds = new DataSet();
result1 = MY XML STRING FROM FETCHXML
StringReader rdr;
rdr = new StringReader(result1);
ds.ReadXml(rdr);
GridView1.DataSource = ds.Tables[1];
GridView1.DataBind();
If I don't set AutoGenerateColumns="false" in the Gridview, it does not display the "ppl.amount" element or the ppl.transactioncurrencyid element. I need those two columns to show in the Gridview as well.
Can someone help me get this figured out please??
Thanks a lot!