all groups > dotnet xml > july 2004 >
You're in the

dotnet xml

group:

Looking for Advice


Looking for Advice Wayne Wengert
7/27/2004 8:48:53 AM
dotnet xml:
I am looking for pointers to good beginner books, tutorials or other
resources to help me understand how to really use XML data. I program mostly
in VB (I have several applications in VB6 but am just starting to convert to
VB.NET). Most of my database backends are SQL Server 2000 with a few still
Access. I want to educate myself so that I can code (and understand)
processes like reading an XML file and adding the contained information to
appropriate tables. I also want to do the reverse, create valid XML from
tables/queries.

An example of what I am trying to accomplish is as follows (sample XML file
at end)

The XML file consists of sets of <Shows> elements which, in turn, each
contain specific information about the show and one or more <PerfSched>
elements. The <PerfSched> elements contain the information about each units
scheduled performance. For each occurrence of <Shows> I want to add a record
to a "Shows" table with the contained values. Also, for each occurrence of
<PerfSched> I want to add a record to a "Performance" table.

In the examples I've found via google, most of the processes appear to
"walk" through the nodes serially. I can see how to pull the values from the
current node so that I can add them to the table but when I get to the first
<PerfSched> tag that is at the end of the <Shows> elements I am not clear on
exactly what to do next? Should I skip to the next <Shows> element (how?)
until I process all of them and then go back to process the <PerfSched>
elements or should I process those child elements as they occur. If the
latter, how do I go "back up" when I reach the next parent node <Shows>.

A big part of my problem is uncertainty how to navigate around in the DOM so
pointers to material that clarifies that would be a gig help.

Thanks for any and all advice.

Wayne


============ XML File ===============
<?xml version="1.0" ?>
<NewDataSet>
<Shows>
<RegionalID>Denver</RegionalID>
<SeqNbr>1</SeqNbr>
<ShowName>Denver SA Prelims Rnd 1</ShowName>
<ShowDate>2004-07-24T00:00:00.0000000-06:00</ShowDate>
<Type>SC</Type>
<PorF>P</PorF>
<Round>1</Round>
<Eqp1Judge>ADAMO S</Eqp1Judge>
<Mov1Judge>ADAMS R</Mov1Judge>
<Ens1Judge>BEENS E</Ens1Judge>
<GE1Judge>ANDERSON M</GE1Judge>
<GE2Judge>BERTELLE S</GE2Judge>
<TaPJudge>ARGY T</TaPJudge>
<PerfSched>
<RegionalID>Denver</RegionalID>
<SeqNbr>1</SeqNbr>
<PerfTime>2004-07-24T09:00:00.0000000-06:00</PerfTime>
<UnitID>10</UnitID>
<Nickname>Arapahoe HS WG</Nickname>
<Class>SA</Class>
</PerfSched>
<PerfSched>
<RegionalID>Denver</RegionalID>
<SeqNbr>1</SeqNbr>
<PerfTime>2004-07-24T09:08:00.0000000-06:00</PerfTime>
<UnitID>606</UnitID>
<Nickname>Loveland HS CG</Nickname>
<Class>SA</Class>
</PerfSched>
<PerfSched>
<RegionalID>Denver</RegionalID>
<SeqNbr>1</SeqNbr>
<PerfTime>2004-07-24T09:16:00.0000000-06:00</PerfTime>
<UnitID>1944</UnitID>
<Nickname>Arvada West</Nickname>
<Class>SA</Class>
</PerfSched>
<PerfSched>
<RegionalID>Denver</RegionalID>
<SeqNbr>1</SeqNbr>
<PerfTime>2004-07-24T09:24:00.0000000-06:00</PerfTime>
<UnitID>1790</UnitID>
<Nickname>Santa Monica</Nickname>
<Class>SA</Class>
</PerfSched>
</CGShows>
<Shows>
<RegionalID>Denver</RegionalID>
<SeqNbr>2</SeqNbr>
<ShowName>Denver SA Prelims Rnd 2</ShowName>
<ShowDate>2004-07-24T00:00:00.0000000-06:00</ShowDate>
<Type>SC</Type>
<PorF>P</PorF>
<Round>2</Round>
<Eqp1Judge>ADAMO S</Eqp1Judge>
<Mov1Judge>ADAMS R</Mov1Judge>
<Ens1Judge>BEENS E</Ens1Judge>
<GE1Judge>ANDERSON M</GE1Judge>
<GE2Judge>BERTELLE S</GE2Judge>
<TaPJudge>ARGY T</TaPJudge>
<PerfSched>
<RegionalID>Denver</RegionalID>
<SeqNbr>2</SeqNbr>
<PerfTime>2004-07-24T10:00:00.0000000-06:00</PerfTime>
<UnitID>1942</UnitID>
<Nickname>Mt. Crest HS</Nickname>
<Class>SA</Class>
</PerfSched>
<PerfSched>
<RegionalID>Denver</RegionalID>
<SeqNbr>2</SeqNbr>
<PerfTime>2004-07-24T10:08:00.0000000-06:00</PerfTime>
<UnitID>297</UnitID>
<Nickname>Tahlequah WG</Nickname>
<Class>SA</Class>
</PerfSched>
<PerfSched>
<RegionalID>Denver</RegionalID>
<SeqNbr>2</SeqNbr>
<PerfTime>2004-07-24T10:16:00.0000000-06:00</PerfTime>
<UnitID>98</UnitID>
<Nickname>Bear Creek CG</Nickname>
<Class>SA</Class>
</PerfSched>
<PerfSched>
<RegionalID>Denver</RegionalID>
<SeqNbr>2</SeqNbr>
<PerfTime>2004-07-24T10:24:00.0000000-06:00</PerfTime>
<UnitID>1510</UnitID>
<Nickname>Broomfield HS</Nickname>
<Class>SA</Class>
</PerfSched>
<PerfSched>
<RegionalID>Denver</RegionalID>
<SeqNbr>2</SeqNbr>
<PerfTime>2004-07-24T10:32:00.0000000-06:00</PerfTime>
<UnitID>231</UnitID>
<Nickname>Vista HS</Nickname>
<Class>SA</Class>
</PerfSched>
</CGShows>
<Shows>
<RegionalID>Denver</RegionalID>
<SeqNbr>3</SeqNbr>
<ShowName>Denver IO/SO Prelims</ShowName>
<ShowDate>2004-07-24T00:00:00.0000000-06:00</ShowDate>
<Type>SC</Type>
<PorF>P</PorF>
<Round>0</Round>
<Eqp1Judge>CAMPBELL J</Eqp1Judge>
<Mov1Judge>OLIVIERO G</Mov1Judge>
<Ens1Judge>BEENS E</Ens1Judge>
<GE1Judge>ANDERSON M</GE1Judge>
<GE2Judge>COSTANZA C</GE2Judge>
<TaPJudge>ARGY T</TaPJudge>
<PerfSched>
<RegionalID>Denver</RegionalID>
<SeqNbr>3</SeqNbr>
<PerfTime>2004-07-24T11:00:00.0000000-06:00</PerfTime>
<UnitID>1564</UnitID>
<Nickname>Revolution WG</Nickname>
<Class>IO</Class>
</PerfSched>
<PerfSched>
<RegionalID>Denver</RegionalID>
<SeqNbr>3</SeqNbr>
<PerfTime>2004-07-24T11:09:00.0000000-06:00</PerfTime>
<UnitID>1890</UnitID>
<Nickname>Stampede</Nickname>
<Class>IO</Class>
</PerfSched>
<PerfSched>
<RegionalID>Denver</RegionalID>
<SeqNbr>3</SeqNbr>
<PerfTime>2004-07-24T11:18:00.0000000-06:00</PerfTime>
<UnitID>421</UnitID>
<Nickname>Alchemy</Nickname>
<Class>IO</Class>
</PerfSched>
<PerfSched>
<RegionalID>Denver</RegionalID>
<SeqNbr>3</SeqNbr>
<PerfTime>2004-07-24T11:27:00.0000000-06:00</PerfTime>
<UnitID>0</UnitID>
<Nickname>*BREAK</Nickname>
<Class />
</PerfSched>
<PerfSched>
<RegionalID>Denver</RegionalID>
<SeqNbr>3</SeqNbr>
<PerfTime>2004-07-24T11:45:00.0000000-06:00</PerfTime>
<UnitID>1050</UnitID>
<Nickname>Dakota Ridge</Nickname>
<Class>SO</Class>
</PerfSched>
<PerfSched>
<RegionalID>Denver</RegionalID>
<SeqNbr>3</SeqNbr>
Re: Looking for Advice Dino Chiesa [Microsoft]
7/27/2004 7:57:20 PM
It seems to me ...

The example XML you showed was generated as a DataSet.
You can save and read DataSets to/from XML in just one method call.
You don't need to walk the DOM of the XML file and add a record to a shows
table, and another record to a Performance table. That sort of thing is
done automatically.

Where did you get the DataSet?
When you save a DataSet from memory to an XML stream or file, it is also
possible to save the schema. If you have access to the schema, then you can
create your own DataSet that conforms to that schema and slurp in that XML
file.

Then you have the Shows table and the Performances table and so on.

If I were you I would not follow the examples that show reading XML
serially, going from one node to the next. Acquaint yourself with ADO.NET
DataSets, as well as XML Serialization, which does these things for you
automatically.

To learn more, In addition to the XML Developer Center on MSDN
http://msdn.microsoft.com/xml/

....I recommend www.topxml.com

-D



[quoted text, click to view]
Re: Looking for Advice Wayne Wengert
7/27/2004 8:19:48 PM
The problem is that although the XML was created in .NET, the application
that is reading it is not .NET - it is plain old VB6/ADO.

Wayne

[quoted text, click to view]
Re: Looking for Advice Dino Chiesa [Microsoft]
7/28/2004 1:38:30 AM
Ahh, my misunderstanding.
I think this group is mostly focused around programming XML in .NET.

I am not as familiar with MSXML but
believe you can do selectNodes(...) on an element, selecting by Xpath.
Then you will get all nodes in the doc of a particular name (eg, all Shows,
then all performances).
This may or may not be what you want.

topxml.com has more examples and tutorials.

-D

[quoted text, click to view]
Re: Looking for Advice Wayne Wengert
7/28/2004 5:07:21 AM
Thanks for the pointer. I'll check it out.

Wayne

[quoted text, click to view]
AddThis Social Bookmark Button