?
Solved

500pts: Specify XML field types i.e. Integer, string, DateTime so Dataset.ReadXML creates field types correct?

Posted on 2006-06-29
1
Medium Priority
?
322 Views
Last Modified: 2011-09-20
Hi there,

I have written a webservice which returns an xml file. I was wondering if its possible to specify each field weather it contains a string or is a decimal,integer or datetime for example? As i use the ReadXml method of dataset to import the xml file, i think its importing each field as a string

here is an example of my XML file which my webservice returns, if anybody knows a solution i would be really grateful... Thanks in advance

specifically its fields NUM and VALUE which i would like to specify as "decimal" so that when i use ReadXML on the dataset object it would import these fields as decimals rather than strings

  <?xml version="1.0" encoding="utf-8" ?>
- <response>
  <Error code="0" description="OK" />
- <myData>
- <Record>
  <COD>abcd123</COD>
  <NOMBRE>company a</NOMBRE>
  <NUM>560</NUM>
  <VALUE>5250,39</VALUE>
  </Record>
- <Record>
  <COD>ccfg45</COD>
  <NOMBRE>Company b</NOMBRE>
  <NUM>30000</NUM>
  <VALUE>342900</VALUE>
  </Record>
  </myData>
  </response>
0
Comment
Question by:ianinspain
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 35

Accepted Solution

by:
mrichmon earned 2000 total points
ID: 17011108
As far as I understand it is always going to read as a string if you use the ReadXml.  You can also read a schema in using the ReadXmlSchema and the datatypes can be defined in the schema:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemdatadatasetclassreadxmlschematopic.asp

Another option is to include the datatypes in the xml - but I think you may have to manually convert.

For example:

<value dt:dt="boolean">1</value>
0

Featured Post

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Suggested Courses

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question