473,396 Members | 1,998 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Better Form

I have an XML document (see below) in which I have a <COMPANY> element that,
in turn, contains other elements. Based on an example I saw somewhere I
coded it as shown in the sample. In purusing other posts and books I see
alternatives such as:

<COMPANY name="My Comapny Name
<City>Podunk</City>
.................

and another alternative:

<COMPANY>
<Name>My Company Name</Name>
<City>Podunk</City>
.................

What are the pros and cons of these approaches? From what I've seen, .NET
creates the format shown in the sample belw when you convert a dataset to
XML

Wayne

================= sample xml ================
<?xml version="1.0"?>
<root xmlns="http://tempuri.org/SC308Hayward CG7.xsd">
<COMPANY>My Company Name
<City>Podunk</City>
<State>IA</State>
<Contact>Joness, Jimmy</Contact>
.............
</COMPANY>
............
</root>
Nov 12 '05 #1
2 2782
A) If you have a DataTable "COMPANY" and you create the column "Name" with
ColumnMapping = MappingType.Element, the DataSet creates an XML file like
this:
<COMPANY>
<Name>My Company Name</Name>
<City>Podunk</City>
...
</COMPANY>

B) If you create the column with ColumnMapping = MappingType.Attribute, the
XML file will be like this:
<COMPANY Name="My Company Name">
<City>Podunk</City>
...
</COMPANY>

C) If you create the column with ColumnMapping = MappingType.Hidden, the XML
file will be like this: (the column "Name" is hidden)
<COMPANY>
<City>Podunk</City>
...
</COMPANY>

D) If you create the column with ColumnMapping = MappingType.SimpleContent,
the XML file will be like this:
<COMPANY City="Podunk"...>My Company Name</COMPANY>
(COMPANY can't have elements, only attributes beside the SimpleContent, City
and other columns must have MappingType.Attribute. Don't use your sample
xml)
If you read the XML files back, by A) and B) you get the same DataSet
(except ColumnMapping). By C) you has no column "Name", by D) you has a
column "COMPANY_Text" instead of "Name"

If the DataSet has a flat hierarchie or the DataTable has many columns, I
prefer A)
If the DataSet has a deep hierarchie or the DataTable has few columns, or
the table has subtables (elements with complex type), I prefer B). For a
computer it doesn't matter, only if people read the XML file.

What about performance? Has anybody tested A) versus B) ?

IF you use an XSD schema:
By objects with complex type you have to use elements, by objects with
simple type you can use generally attributes, if you need a special order
than use however a sequence with elements.
Jaga


Nov 12 '05 #2
Thanks for all that information Jaga

Wayne

"Jaga" <ja***@web.de> wrote in message
news:OC**************@tk2msftngp13.phx.gbl...
A) If you have a DataTable "COMPANY" and you create the column "Name" with
ColumnMapping = MappingType.Element, the DataSet creates an XML file like
this:
<COMPANY>
<Name>My Company Name</Name>
<City>Podunk</City>
...
</COMPANY>

B) If you create the column with ColumnMapping = MappingType.Attribute, the XML file will be like this:
<COMPANY Name="My Company Name">
<City>Podunk</City>
...
</COMPANY>

C) If you create the column with ColumnMapping = MappingType.Hidden, the XML file will be like this: (the column "Name" is hidden)
<COMPANY>
<City>Podunk</City>
...
</COMPANY>

D) If you create the column with ColumnMapping = MappingType.SimpleContent, the XML file will be like this:
<COMPANY City="Podunk"...>My Company Name</COMPANY>
(COMPANY can't have elements, only attributes beside the SimpleContent, City and other columns must have MappingType.Attribute. Don't use your sample
xml)
If you read the XML files back, by A) and B) you get the same DataSet
(except ColumnMapping). By C) you has no column "Name", by D) you has a
column "COMPANY_Text" instead of "Name"

If the DataSet has a flat hierarchie or the DataTable has many columns, I
prefer A)
If the DataSet has a deep hierarchie or the DataTable has few columns, or
the table has subtables (elements with complex type), I prefer B). For a
computer it doesn't matter, only if people read the XML file.

What about performance? Has anybody tested A) versus B) ?

IF you use an XSD schema:
By objects with complex type you have to use elements, by objects with
simple type you can use generally attributes, if you need a special order
than use however a sequence with elements.
Jaga

Nov 12 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

19
by: Rhek | last post by:
Hello, I would like to apologize for double posting this question because I posted this same question in what looks like the VB 6 newgroups and not the .Net newsgroup... Here goes: The code...
15
by: ham-z | last post by:
I have written the following Win app in VB.NET 2003 . The class is simply picture boxes that behave in a random order after they have been instantiated and added to a form. When I create 15 or more...
9
by: Randell D. | last post by:
Folks, I have a large amount of values to store (we're talking tens, if not hundreds of bytes). I need this for a client side application - ignore the security consequences for the moment -...
19
by: James Fortune | last post by:
I have a lot of respect for David Fenton and Allen Browne, but I don't understand why people who know how to write code to completely replace a front end do not write something that will automate...
10
by: Regnab | last post by:
I'm making a database to record training that employees have recieved. For each training excercise, they recieve a mark between 1 and 3. Initially, when there weren't so many training elements, I...
1
by: Chad A. Beckner | last post by:
Hey all, I am developing a workshop registration system, and am new to ASP .NET. On my first page, I want to list the "categories" available along with the number of "workshops" related to that...
6
by: Richard Brown | last post by:
Ok, I celebrate and rejoice in the Anchor property. So wonderful compared to the horrible 'resize' code I had to write in VB6, there is just no end to the wonders of VB.NET..... uh, ok..... BUT......
16
by: Breana | last post by:
Man i am getting a tumor over this. Ok this morning i noticed my game page was all messed up. I moved my site to a new server banner less :) it was all ok last night but now hell. So i re did the...
84
by: Patient Guy | last post by:
Which is the better approach in working with Javascript? 1. Server side processing: Web server gets form input, runs it into the Javascript module, and PHP collects the output for document prep....
7
by: raylopez99 | last post by:
I find that I am using bool variables a lot when I code in Forms. I know how to overload event handlers, and that's great for offloading code from the 'base' event handler and/or creating helper...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.