I have an xml file like the below one, read the file using DataSet.ReadXML method, and returns dataset with tables with additional column Criteria_Id which is breaking the application. How can I determine a column has been automatically added? or How can
I stop autogenerating such columns??
Accroding to your description and codes,as far as I think,when you use dataset readxml method to read the file,it will create another tabel because of the repeat node base on the dependencies of dataset.So ,I suggest you could preloaded dataset to datatable
and set XmlReadMode to be auto or IgnoreSchema.
Besides,I suggest you best to use linq to xml.Duplicate nodes are not allowed in dataset.
.NET forums are moving to a new home on Microsoft Q&A, we encourage you to go to Microsoft Q&A for .NET for posting new questions and get involved today.
Participant
1042 Points
658 Posts
DataSet ReadXml to skip autoid
Mar 31, 2020 03:39 PM|krisrajz|LINK
I have an xml file like the below one, read the file using DataSet.ReadXML method, and returns dataset with tables with additional column Criteria_Id which is breaking the application. How can I determine a column has been automatically added? or How can I stop autogenerating such columns??
<ReportName><Criteria><ProfRegion><![CDATA['INR']]></ProfRegion><ProfDGOffice><![CDATA[All]]></ProfDGOffice><ProfDGOrgUnit><![CDATA[All]]></ProfDGOrgUnit><Approver_txt><![CDATA[All]]></Approver_txt><PA><![CDATA[All]]></PA><TimeStatus><![CDATA[All]]></TimeStatus><ProfCategory><![CDATA[All]]></ProfCategory><ProfType><![CDATA[All]]></ProfType><Exemptstatus><![CDATA[All]]></Exemptstatus><NationalPractice><![CDATA[All]]></NationalPractice><TimePrd><![CDATA[LW]]></TimePrd><StartDate><![CDATA[3/23/2020]]></StartDate><EndDate><![CDATA[3/29/2020]]></EndDate><WebServerReportPath><![CDATA[http://urlt/]]></WebServerReportPath><Prof_txt><![CDATA[All]]></Prof_txt><RequireFollowup><![CDATA[N]]></RequireFollowup><ShowMissingTime><![CDATA[N]]></ShowMissingTime><ProfStatus><![CDATA[All]]></ProfStatus><WebServerReportPath><![CDATA[http://rurl/]]></WebServerReportPath></Criteria></ReportName>
Raj
Remember to click Mark as Answer on the post that helps to others.
All-Star
53041 Points
23619 Posts
Re: DataSet ReadXml to skip autoid
Mar 31, 2020 03:57 PM|mgebhard|LINK
There is no Criteria_Id in the XML shown. Can you share the error message or enough code to reproduce this issue?
Contributor
3730 Points
1420 Posts
Re: DataSet ReadXml to skip autoid
Apr 01, 2020 08:14 AM|yij sun|LINK
Hi krisrajz,
Accroding to your description and codes,as far as I think,when you use dataset readxml method to read the file,it will create another tabel because of the repeat node base on the dependencies of dataset.So ,I suggest you could preloaded dataset to datatable and set XmlReadMode to be auto or IgnoreSchema.
Besides,I suggest you best to use linq to xml.Duplicate nodes are not allowed in dataset.
More details,you could refer to below codes:
More details,you could refer to below article:
https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/concepts/linq/linq-to-xml-overview
Best regards,
Yijing Sun