Xml document viewing

I need to load xml document in c# sharp application through command ta

Page 1 of 1

4 Replies - 887 Views - Last Post: 23 September 2009 - 05:59 AM Rate Topic: -----

#1 sent_sara  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 22-September 09

Xml document viewing

Post icon  Posted 22 September 2009 - 11:19 PM

I need to load xml document in c# sharp application through command task
Is This A Good Question/Topic? 0
  • +

Replies To: Xml document viewing

#2 janne_panne  Icon User is offline

  • WinRT Dev
  • member icon

Reputation: 429
  • View blog
  • Posts: 1,047
  • Joined: 09-June 09

Re: Xml document viewing

Posted 22 September 2009 - 11:57 PM

And..?

Why do you need our help? Or did you just came to tell us what you need to do? Well, blogs are for that, not forums.
Was This Post Helpful? 0
  • +
  • -

#3 PsychoCoder  Icon User is offline

  • Google.Sucks.Init(true);
  • member icon

Reputation: 1637
  • View blog
  • Posts: 19,853
  • Joined: 26-July 07

Re: Xml document viewing

Posted 22 September 2009 - 11:58 PM

Dream.In.Code has a policy by which we prefer to see a good faith effort on your part before providing source code for homework assignments. Please post the code you have written in an effort to resolve the problem, and our members would be happy to provide some guidance. Be sure to include a description of any errors you are encountering as well.

Post your code like this: :code:

Thanks.
Was This Post Helpful? 0
  • +
  • -

#4 sent_sara  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 22-September 09

Re: Xml document viewing

Posted 23 September 2009 - 12:26 AM

View PostPsychoCoder, on 22 Sep, 2009 - 10:58 PM, said:

Dream.In.Code has a policy by which we prefer to see a good faith effort on your part before providing source code for homework assignments. Please post the code you have written in an effort to resolve the problem, and our members would be happy to provide some guidance. Be sure to include a description of any errors you are encountering as well.

Post your code like this: :code:

Thanks.


spec.xml content

<?xml version="1.0" encoding="utf-8"?>
<spec>
	<make>HCL</make>
	<RAM>256</RAM>
	<price>15000</price>
</spec>



[c# code content]
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Xml;

namespace XmlGeneration
{
	public partial class Form1 : Form
	{
		public Form1()
		{
			InitializeComponent();
		}

		private void button1_Click(object sender, EventArgs e)
		{
			try
			{
				XmlTextReader reader = null;
				while (reader.Read())
				{

				}
				XmlDocument doc = new XmlDocument();
				doc.LoadXml("spec.xml");
			}
			catch (Exception e)
			{
				MessageBox("the exception caught is " + e);

			}
		}
	}
}



when i try to click the Load task , i need to view the xml content into textbox1,textbox2,textbox3,textbox
I don't know how to start with this..attached the screen shot of UI
Was This Post Helpful? 0
  • +
  • -

#5 eclipsed4utoo  Icon User is offline

  • Not Your Ordinary Programmer
  • member icon

Reputation: 1524
  • View blog
  • Posts: 5,957
  • Joined: 21-March 08

Re: Xml document viewing

Posted 23 September 2009 - 05:59 AM

if you are using .Net 3.5, you can use this...

XDocument doc = Xdocument.Load(pathToFile);
XElement element = doc.Root;

string make = element.Element("make").Value;
string ram = element.Element("ram").Value;
string price = element.Element("price").Value;


Was This Post Helpful? 0
  • +
  • -

Page 1 of 1