I have limited XML skills and am completely baffled by how to validate an XMLDocument using a DataSet schema.
Let me explain, I have a web service with an XMLDocument as it's main input parameter.
This XML needs loading into my database. I can successfully do this as follows:-
oraCmd = new OracleCommand("MyOracleTable", oraConn); oraCmd.CommandType = CommandType.TableDirect; // get Data Adapter oraDA = new OracleDataAdapter(); oraDA.SelectCommand = oraCmd; // Create ins procs for saving data OracleCommandBuilder oraCmdBuilder = new OracleCommandBuilder(oraDA); oraDA.InsertCommand = oraCmdBuilder.GetInsertCommand(); // get schema for DataSet DataSet oraDS = new DataSet(); oraDS.DataSetName = "Plan"; oraDA.FillSchema(oraDS, SchemaType.Source, "PlanDetails"); // Validate XML, using schema // Read XML into Dataset XmlTextReader r = new XmlTextReader(xd.OuterXml, XmlNodeType.Document, null); oraDS.ReadXml(r); // save to DB int rowsAffected = oraDA.Update(oraDS, "PlanDetails");
So the problem comes when for example text has been entered into the XML element destined for a numeric field I get the error " Input string was not in a correct format". I would like to validate the XML using the table schema loaded into the DataSet, and produce a nice validation error list for feedback to the user, rather than it just falling over.
.NET Development14
|