4 Replies - 576 Views - Last Post: 13 January 2010 - 06:10 PM Rate Topic: -----

#1 poncho4all  Icon User is offline

  • D.I.C Head!
  • member icon

Reputation: 123
  • View blog
  • Posts: 1,405
  • Joined: 15-July 09

Problems with Tutorial

Posted 13 January 2010 - 05:29 PM

Well im reading this tutorial

Working With XML Files in C#

But im having problems with this part

<?xml version="1.0"?>
<CompSpecs>
<CP>
<Type>Dell Dimension 6600</Type>
<RAM>2GBs</RAM>
<CPU_Speed>2.8Ghz</CPU_Speed>
</CP>
</CompSpecs>


What is this supposed to be?
Where do i put it?
I have Microsoft Office 2010 does this affect?

I know its a dum question but i have to ask it :P

Is This A Good Question/Topic? 0
  • +

Replies To: Problems with Tutorial

#2 n8wxs  Icon User is offline

  • --... ...-- -.. . -. ---.. .-- -..- ...
  • member icon

Reputation: 972
  • View blog
  • Posts: 3,878
  • Joined: 07-January 08

Re: Problems with Tutorial

Posted 13 January 2010 - 05:55 PM

<?xml version="1.0"?>
<CompSpecs>
<CP>
<Type>Dell Dimension 6600</Type>
<RAM>2GBs</RAM>
<CPU_Speed>2.8Ghz</CPU_Speed>
</CP>
</CompSpecs>



The above needs to copied to a file. It is the data the XML process will operate on.

Looking at the tutorial:
...
string path = openFileDialog1.FileName; // The Path to the .Xml file //
FileStream READER = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite); //Set up the filestream (READER) //
System.Xml.XmlDocument CompSpecs = new System.Xml.XmlDocument();// Set up the XmlDocument (CompSpecs) //
CompSpecs.Load(READER); //Load the data from the file into the XmlDocument (CompSpecs) //
...


you can see that an openFileDialog() is used to tell the program where the above data file is located. Next a file reader is created to read the contents of the file. A new instance of an XML document is created, named ComSpecs.
Finally the data in the external file is read and loaded into ComSpecs.
Was This Post Helpful? 0
  • +
  • -

#3 poncho4all  Icon User is offline

  • D.I.C Head!
  • member icon

Reputation: 123
  • View blog
  • Posts: 1,405
  • Joined: 15-July 09

Re: Problems with Tutorial

Posted 13 January 2010 - 06:02 PM

Yea i thought about that but i dont know wich kind of file it needs to be copied to.
It says an .xml file but, in wich way?

Ive tried (row1, col1) (row1, col2) (row1, col3)
Dell Dimension 6600 2GBs 2.8Ghz

Also tried
(row1, col1) Dell Dimension 6600
(row2, col1) 2GBs
(row3, col1) 2.8Ghz


Neither worked :(

So im just wondering did i misunderstood?

is it a different kind of file i need to load?
Was This Post Helpful? 0
  • +
  • -

#4 papuccino1  Icon User is offline

  • His name was Robert Paulson.
  • member icon

Reputation: 63
  • View blog
  • Posts: 1,121
  • Joined: 02-March 08

Re: Problems with Tutorial

Posted 13 January 2010 - 06:05 PM

I think you're a bit confused.

You can create a .txt file, open it with notepad and copypaste the text. Save it. Change the extension to .xml and PAM! You have an XML file.

Inside of Visual C# Express 2008, right click on the project, and select add New Item. XML File.

You will go to a newly created file with only one line.

Paste the same text there and save it.

XML has NOTHING to do with databases or sql or anything of that sort. XML is just a language that allows you to format text in a way that you can easily navigate through it later.

For instance, if you want to save certain strings but don't want to use an SQL database or even a compact database, it's perfectly acceptable to save the information to XML and then use XDocument to retrive the information.

This post has been edited by papuccino1: 13 January 2010 - 06:06 PM

Was This Post Helpful? 1
  • +
  • -

#5 poncho4all  Icon User is offline

  • D.I.C Head!
  • member icon

Reputation: 123
  • View blog
  • Posts: 1,405
  • Joined: 15-July 09

Re: Problems with Tutorial

Posted 13 January 2010 - 06:10 PM

Thanx papuccino1 thats exactly what i needed.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1