Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I feel kinda silly. I use them, I know how to make them... but the XML namespace is like the bermuda triangle for me :D

 

Normally I create a dataset and use LoadXML/LoadSchema. Thats fine for a full database with multiple tables in xml. For a single table its a bit of overkill. You really just need a DataTable.

 

.Net 2.0 has DataTable.Load(Read?)XML/Load(Read)Schema just like the DataSet has.

 

Even a DataTable is overkill for just loading an XML ini file, that is just a bunch of keys with settings like so:

 

<root1>
<setting1></setting1>
<setting2></setting2>
<setting3></setting3>
<setting4></setting4>
<setting5></setting5>
<setting6></setting6>
<setting7></setting7>
<setting8></setting8>
<setting9></setting9>
</root1>

 

What is the best method to get at each of these keys to get the data?

 

How about a very basic database type? without using a DataSet/Table, what is the easiest/best method for getting into this type?

 

<root1>
<data>
	<name></name>
	<date></date>
	<address></address>
	<phoneNumber></phoneNumber>
</data>
<data>
	<name></name>
	<date></date>
	<address></address>
	<phoneNumber></phoneNumber>
</data>
</root1>

 

I think these answers would help to clarify how to better use XML for settings and basic data for everyone.

 

Thank you :)

  • *Experts*
Posted

The absolute easiest way I see for saving settings is to use XML serializarion (may not sound that simple when you use serialization for the first time :)). When you serialize something using XML the whole state of an object is written to a .xml file. Create a class, mark it as serializable, make all the variables you need that represent settings and simple serialize the settings when you need to, or deserialize (read back the object into memory) them when you need to.

If you need to know how to do that, just post :).

Posted

I think I needed to do that for a component... then realized that you couldn't do it with components themselves (because of what they inherited). Then I realized that I could include all of the component variables in a class and make that object serializable...

 

So you have to imagine me spending 2 hours getting it to work, realizing it doesn't... spending 2 hours finding a ghetto workaround to keep the project rolling (.mdb file for settings! ewww :p), then realizing that components also have classes so I can make those classes serializable... It was one of those days that I would have pulled my hair out if I wern't bald :D

 

XML is one of the most intimidatable things in programming it seems for how easy it actually is. I think it's all of the Jargon and 'add-ons' (schema and other related files) that scares people.

 

I know I have the concept down, but when it comes to actually using the XML namespace, I start to get frustrated because I don't have all of the Jargon down, just the concepts. When nodes and elements go flying and I deviate from a tutorial in the slightest way, things stop working. :eek:

 

So I figured I'd ask here. I forgot about xml serialization. Maybe I'll do up an easy to follow tutorial or something on it.

 

Anyone know of any relatively simple ways to get into simple database style XML documents without going into the DataSet Object?

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...