Solved

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

Posted on 2006-06-29
1
314 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
1 Comment
 
LVL 35

Accepted Solution

by:
mrichmon earned 500 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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Introduction                                                 Was the var keyword really only brought out to shorten your syntax? Or have the VB language guys got their way in C#? What type of variable is it? All will be revealed.   Also called…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

708 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now