PC Review


Reply
Thread Tools Rate Thread

Can I create DataSet in the designer and use it to parse xml file?

 
 
Dan
Guest
Posts: n/a
 
      16th Sep 2009
Hi,

Can I use the designer to create a typed DataSet and then use it to parse
xml file?

If yes, could someone please describe the necessary steps or point me to
on-line docs?

For example, how would I define a DataSet in the designer for the following
xml:
[...]
<parent>
<parent_id>1</parent_id>
<name>parent1</name>
<child>
<child_id>1</child_id>
<name>child1</name>
</child>
<child>
<child_id>2</child_id>
<name>child2</name>
</child>
</parent>
<parent>
[...]
</parent>

I'd appreciate _any_ suggestions.
Thanks,
Dan


 
Reply With Quote
 
 
 
 
Scott M.
Guest
Posts: n/a
 
      16th Sep 2009
DataSet.ReadXml


"Dan" <(E-Mail Removed)> wrote in message
news:u%(E-Mail Removed)...
> Hi,
>
> Can I use the designer to create a typed DataSet and then use it to parse
> xml file?
>
> If yes, could someone please describe the necessary steps or point me to
> on-line docs?
>
> For example, how would I define a DataSet in the designer for the
> following xml:
> [...]
> <parent>
> <parent_id>1</parent_id>
> <name>parent1</name>
> <child>
> <child_id>1</child_id>
> <name>child1</name>
> </child>
> <child>
> <child_id>2</child_id>
> <name>child2</name>
> </child>
> </parent>
> <parent>
> [...]
> </parent>
>
> I'd appreciate _any_ suggestions.
> Thanks,
> Dan
>



 
Reply With Quote
 
Scott M.
Guest
Posts: n/a
 
      16th Sep 2009
Sorry, didn't read that carefully enough.

The designer isn't going to be useful to create actual XML that has data in
it. The designer is for creating a schema that some XML must adhere to for
it to be considered valid.

-Scott

"Scott M." <s-(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> DataSet.ReadXml
>
>
> "Dan" <(E-Mail Removed)> wrote in message
> news:u%(E-Mail Removed)...
>> Hi,
>>
>> Can I use the designer to create a typed DataSet and then use it to parse
>> xml file?
>>
>> If yes, could someone please describe the necessary steps or point me to
>> on-line docs?
>>
>> For example, how would I define a DataSet in the designer for the
>> following xml:
>> [...]
>> <parent>
>> <parent_id>1</parent_id>
>> <name>parent1</name>
>> <child>
>> <child_id>1</child_id>
>> <name>child1</name>
>> </child>
>> <child>
>> <child_id>2</child_id>
>> <name>child2</name>
>> </child>
>> </parent>
>> <parent>
>> [...]
>> </parent>
>>
>> I'd appreciate _any_ suggestions.
>> Thanks,
>> Dan
>>

>
>



 
Reply With Quote
 
Dan
Guest
Posts: n/a
 
      16th Sep 2009
Scott,

Thanks for a quick reply. My original post was probably not that clear
because "...The designer is for creating a schema that some XML must adhere
to for it to be considered valid..." is exactly what I'd like to do .

Given the example in my original post, how do I create a corresponding
DataSet in the designer?

I'm guessing that I'd need to do the following:

In the designer:
1) create an empty dataset
2) add 2 tables: parent and child
3) define columns for the above tables
4) Q: how do I define relations between parent and child tables? What key
do I use?

In code:
1) instantiate DataSet object based on the class auto-generated above
2) call ReadXml()

Is the above approach somewhat correct?

Again, any help will be greatly appreciated.

Dan



"Scott M." <s-(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Sorry, didn't read that carefully enough.
>
> The designer isn't going to be useful to create actual XML that has data
> in it. The designer is for creating a schema that some XML must adhere to
> for it to be considered valid.
>
> -Scott
>
> "Scott M." <s-(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> DataSet.ReadXml
>>
>>
>> "Dan" <(E-Mail Removed)> wrote in message
>> news:u%(E-Mail Removed)...
>>> Hi,
>>>
>>> Can I use the designer to create a typed DataSet and then use it to
>>> parse xml file?
>>>
>>> If yes, could someone please describe the necessary steps or point me to
>>> on-line docs?
>>>
>>> For example, how would I define a DataSet in the designer for the
>>> following xml:
>>> [...]
>>> <parent>
>>> <parent_id>1</parent_id>
>>> <name>parent1</name>
>>> <child>
>>> <child_id>1</child_id>
>>> <name>child1</name>
>>> </child>
>>> <child>
>>> <child_id>2</child_id>
>>> <name>child2</name>
>>> </child>
>>> </parent>
>>> <parent>
>>> [...]
>>> </parent>
>>>
>>> I'd appreciate _any_ suggestions.
>>> Thanks,
>>> Dan
>>>

>>
>>

>
>



 
Reply With Quote
 
Gregory A. Beamer
Guest
Posts: n/a
 
      17th Sep 2009
"Dan" <(E-Mail Removed)> wrote in
news:u#(E-Mail Removed):

> Hi,
>
> Can I use the designer to create a typed DataSet and then use it to
> parse xml file?
>
> If yes, could someone please describe the necessary steps or point me
> to on-line docs?
>
> For example, how would I define a DataSet in the designer for the
> following xml:
> [...]
> <parent>
> <parent_id>1</parent_id>
> <name>parent1</name>
> <child>
> <child_id>1</child_id>
> <name>child1</name>
> </child>
> <child>
> <child_id>2</child_id>
> <name>child2</name>
> </child>
> </parent>
> <parent>
> [...]
> </parent>
>
> I'd appreciate _any_ suggestions.


Yes and no.

Earlier versions of Visual Studio had better features for creating an
XML Schema and not merely a DataSet. If you are aiming for XML schema,
you might find your designed schema is not accurate. If, however, a
DataSet is what you are testing against, then you should be fun. That is
the designer gotcha.

As for validation, Scott's suggestion will work, since your XSD is a
DataSet. If it fails to load, it is not valid.

But, that is not the answer you want. You can also use a validating
reader and add the schema in question to the reader. This will validate
the XML to schema, while giving you some clue of why the XML is not
valid (loading a DataSet merely gives an exception).

Peace and Grace,

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

Twitter: @gbworld
Blog: http://gregorybeamer.spaces.live.com

My vacation and childhood cancer awareness site:
http://www.crazycancertour.com

*******************************************
| Think outside the box! |
*******************************************
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Visual Studio DataSet designer doesn't regenerate designer.cs code Barney Microsoft C# .NET 3 15th Oct 2007 04:15 PM
DataSet Designer - Create Only a Typed DataTable? Spam Catcher Microsoft VB .NET 0 19th Nov 2006 06:16 PM
Dataset in Visual Studio project - VS crash and designer.cs file disappeared Robert Janik Microsoft Dot NET Compact Framework 0 14th May 2006 05:17 AM
Parse table from one dataset and create new dataset using this table moondaddy Microsoft ADO .NET 2 22nd Oct 2003 11:38 PM
Problem updating existing typed dataset from Generate Dataset designer Eric Kennedy Microsoft ADO .NET 0 29th Aug 2003 05:55 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:41 PM.