For Programmers: Free Programming Magazines  


Home > Archive > Visual Basic Syntax > March 2005 > Use XSD to get data types for XML elements









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Use XSD to get data types for XML elements
RichardF

2005-03-23, 4:00 pm

I am using VB6.

I am receiving an XML file and an XSD file.

I understand I can use the XSD file to validate the XML file, but is
it also possible for me to use the XSD file to give me the data types
of the elements in the XML file?

When processing the XML file, I know the name and the value (e.g.
<FirstName>Richard</FirstName>, <Amount>1.23</Amount> ).

The XSD has the datatypes defined for each element.

What I want to do is, while processing the XML file in my VB program,
also be able to get the data type for that element.

Thanks for any help.

RichardF
RichardF

2005-03-23, 4:00 pm

When I said i know the name and value I meant i know the tage name,
and it's value. My exampls FirstName and Amount may be confusing.
What I meant was, if I have...

<FirstName>Richard</Firstname>
<Amount>1.23</Amount>
<SomeField>123456789</SomeField>

I need to know what the approriate datatype is for each field. i.e.
is SomeField a numeric value or is it a string value, that just
happens to contain numbers in this case.

Hope this helps!

RichardF

On Wed, 23 Mar 2005 09:53:49 -0600, RichardF <noone@nowhere.com>
wrote:

>I am using VB6.
>
>I am receiving an XML file and an XSD file.
>
>I understand I can use the XSD file to validate the XML file, but is
>it also possible for me to use the XSD file to give me the data types
>of the elements in the XML file?
>
>When processing the XML file, I know the name and the value (e.g.
><FirstName>Richard</FirstName>, <Amount>1.23</Amount> ).
>
>The XSD has the datatypes defined for each element.
>
>What I want to do is, while processing the XML file in my VB program,
>also be able to get the data type for that element.
>
>Thanks for any help.
>
>RichardF


Mike D Sutton

2005-03-23, 4:00 pm

> When I said i know the name and value I meant i know the tage name,
> and it's value. My exampls FirstName and Amount may be confusing.
> What I meant was, if I have...
>
> <FirstName>Richard</Firstname>
> <Amount>1.23</Amount>
> <SomeField>123456789</SomeField>
>
> I need to know what the approriate datatype is for each field. i.e.
> is SomeField a numeric value or is it a string value, that just
> happens to contain numbers in this case.


An XSD file is simply an XML file which corresponds to a tightly defined syntax, as such you should simply be able to
use XPath to query the nodes within the XSD file corresponding to the tag you're interested in. Unfortunately I've
never used the format so can't offer much more, however there's plenty of information on the format here:
http://www.w3schools.com/schema/default.asp
You'll find loads of help on using MSXML in VB in the archives (groups.google.com)
Hope this helps,

Mike


- Microsoft Visual Basic MVP -
E-Mail: EDais@mvps.org
WWW: Http://EDais.mvps.org/
----------------------------------------------------------------------------
Read. Decide. Sign the petition to Microsoft.
http://classicvb.org/petition/


RichardF

2005-03-23, 4:00 pm

Thanks for the response.

I have done a lot of searching, and all I can find is how to validate
the XML file.

Once that is successful, I was hoping there would be an easy way to
get the datatype of each element as I was processing the XML file.

I guess not :(

Oh well!

RichardF

On Wed, 23 Mar 2005 16:25:35 -0000, "Mike D Sutton" <EDais@mvps.org>
wrote:

>
>An XSD file is simply an XML file which corresponds to a tightly defined syntax, as such you should simply be able to
>use XPath to query the nodes within the XSD file corresponding to the tag you're interested in. Unfortunately I've
>never used the format so can't offer much more, however there's plenty of information on the format here:
>http://www.w3schools.com/schema/default.asp
>You'll find loads of help on using MSXML in VB in the archives (groups.google.com)
>Hope this helps,
>
> Mike
>
>
> - Microsoft Visual Basic MVP -
>E-Mail: EDais@mvps.org
>WWW: Http://EDais.mvps.org/
>----------------------------------------------------------------------------
>Read. Decide. Sign the petition to Microsoft.
>http://classicvb.org/petition/
>


Martin Honnen

2005-03-23, 4:00 pm



RichardF wrote:

> Once that is successful, I was hoping there would be an easy way to
> get the datatype of each element as I was processing the XML file.


There is a way, I have posted an answer in microsoft.public.xml, see
<news://news.microsoft.com:119/egUGZ...FTNGP14.phx.gbl>
I have not copied the VB groups in as I have not used VB in my example
but check the post in the XML group for a suggestion on how to use the
SOM (schema object model) with MSXML 4.


--

Martin Honnen
http://JavaScript.FAQTs.com/
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com