Creating a column of type Double from a node in an XML file

  • Thread starter Ken Cox [Microsoft MVP]
  • Start date
K

Ken Cox [Microsoft MVP]

Hi,

I'm using a dataset to read data from an XML file. I don't control the XML.
The XML has no schema and therefore is treated like a string. My data
consumer wants the column type to be a Double.

Is there a simple way to change a column from string to double? When I try
to do it, the compiler complaints that I can't change the type after the
data is loaded. Maybe there's a way to do a mapping or alias? Can I create
my own schema and apply it after the data is loaded?

Thanks,

Ken
 
J

John Timney \(ASP.NET MVP\)

Ken,

You can create a schema at load time using inference to determine your
types - I've not done it though and its not intuitive. The schema
over-rides inference as inference is pretty much guess work on the part of
the reader.

http://msdn.microsoft.com/library/d...nferringdatasetrelationalstructurefromxml.asp

Your best bet is create a schema if the data columns are fixed at read time
and rewrite the XML with an inline schema and provide that to your consumer.
These links provide some good examples but you'll need to pick them apart...

http://msdn.microsoft.com/library/d...s/cpguide/html/cpconloadingdatasetfromxml.asp

http://msdn.microsoft.com/library/d...conloadingdatasetschemainformationfromxml.asp


Regards

John Timney
ASP.NET MVP
Microsoft Regional Director
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top