Click here to Skip to main content
15,886,873 members
Home / Discussions / XML / XSL
   

XML / XSL

 
AnswerRe: count nodes with xpath Pin
eggie58-Apr-06 15:13
eggie58-Apr-06 15:13 
QuestionConverting from one line to an indented view Pin
John Owens7-Apr-06 4:12
John Owens7-Apr-06 4:12 
AnswerRe: Converting from one line to an indented view Pin
Michael A. Barnhart14-Apr-06 11:55
Michael A. Barnhart14-Apr-06 11:55 
Questiontrying to provide a user interface for filling in the innertext of an xml document in the web project Pin
Madhur Ahuja7-Apr-06 2:31
Madhur Ahuja7-Apr-06 2:31 
Questionhow to call xml Pin
ybasha6-Apr-06 17:52
ybasha6-Apr-06 17:52 
Questionxml to asp Pin
zybernau4-Apr-06 9:16
zybernau4-Apr-06 9:16 
QuestionMy code doesn't work. Help? Pin
SpeBeeTo4-Apr-06 6:02
SpeBeeTo4-Apr-06 6:02 
QuestionProgrammatically adding TabPage Contents into DataGrid from XML File Pin
AnneThorne3-Apr-06 8:27
AnneThorne3-Apr-06 8:27 
Programmatically adding TabPage Contents into DataGrid from XML File


Hi,

We are creating a C# Windows application using VS 2005.

It reads in an xml file and creates tab pages that each
have a datagrid that holds the specific information
for that tab's node.

We have been able to programmatically give the tab.text
(the label on the tabs), but when we try to add the
specific data for each tab into a datagrid on the
tab's page, all of the data gets added instead of the
data for just that node.

Perhaps we need to clear the grid first???

Any help would be appreciated.

Thank you in advance,
Anne




Here is a portion of the xml file we are using.
<?xml version="1.0" encoding="utf-8"?>
<inspection>
    <inspforms>
        <inspform>
            <name>general</name>
            <sections>
                <section>
                    <tab>Heading</tab>
                    <label>
                        <name>id</name>
                        <type>text</type>
                        <value>
                            <single>200621</single>
                         </value>
                    </label>
                    <label>
                        <name>request
                        </name>
                        <type>text
                        </type>
                        <value>
                            <single>30
                            </single>
                            <choices>
                                <choice>
                                </choice>
                            </choices>
                        </value>
                    </label>
 
                </section>
            </sections>
        </inspform>
        <inspform>
            <name>Risk</name>
            <sections>
                <section>
                    <tab>Operations</tab>
                    <label>
                        <name>Business Type</name>
                        <type>radio</type>
                        <value>
                            <choices>
                                <choice>
                                    <choicename>Corporation</choicename>
                                    <choicevalue>
                                    </choicevalue>
                                </choice>
                                <choice>
                                    <choicename>LLC</choicename>
                                    <choicevalue>
                                    </choicevalue>
                                </choice>
                                <choice>
                                    <choicename> Partnership</choicename>
                                    <choicevalue>
                                    </choicevalue>
                                </choice>
                                <choice>
                                    <choicename>Sole Proprietor</choicename>
                                    <choicevalue>
                                    </choicevalue>
                                </choice>
                            </choices>
                        </value>
                    </label>
                    <label>
                        <name>Years in Business</name>
                        <type>text</type>
                        <value>
                            <single>
                            </single>
                        </value>
                    </label>
                 </section>
            </sections>
        </inspform>
    </inspforms>
</inspection>



Here is the pertinent code:
//frmMain.cs
<br />
using System;<br />
using System.Collections;<br />
using System.ComponentModel;<br />
using System.Data;<br />
using System.Drawing;<br />
using System.Windows.Forms;<br />
<br />
using ABC.Components;<br />
using ABC.Globals;<br />
<br />
namespace ABC.Forms<br />
{<br />
	public class frmMain : System.Windows.Forms.Form<br />
	{<br />
		public  const string Path = @"C:\ABCXmls\abcBase.xml";<br />
		public  ArrayList ArrayListTabs;<br />
<br />
		private ABC.Components.abcTabArea abcTabArea1;<br />
<br />
		private System.ComponentModel.Container components = null;<br />
<br />
		public frmMain()<br />
		{<br />
<br />
			XmlHelper.OpenFile(Path);<br />
			ArrayListTabs = new ArrayList();<br />
			ArrayListTabs = XmlHelper.GetArrayList("tab");<br />
			InitializeComponent();<br />
		}<br />
		#region InitializeComponent()<br />
<br />
		private void InitializeComponent()<br />
		{<br />
			...<br />
<br />
		}<br />
		#endregion<br />
<br />
		[STAThread]<br />
		static void Main() <br />
		{<br />
			Application.Run(new frmMain());<br />
		}<br />
<br />
		private void frmMain_Load(object sender, EventArgs e)<br />
		{<br />
			this.abcTabArea1.CreateTabs(this.ArrayListTabs, Path);<br />
		}<br />
<br />
		protected override void Dispose( bool disposing )<br />
		{<br />
			...<br />
		}<br />
<br />
<br />
	}<br />
	}<br />
}<br />

//xmlHelper.cs
<br />
using System;<br />
using System.Collections;<br />
using System.Data;<br />
using System.IO;<br />
using System.Xml;<br />
<br />
<br />
namespace ABC.Globals<br />
{<br />
	public class XmlHelper<br />
	{<br />
		private static XmlDocument XmlDocument1;<br />
<br />
		public static void OpenFile(string path)<br />
		{<br />
			XmlDocument1 = new XmlDocument();<br />
			XmlDocument1.PreserveWhitespace = false;<br />
			XmlDocument1.Load(path);<br />
		}<br />
		public static ArrayList GetArrayList(string elementName)<br />
		{<br />
			ArrayList arrayList1 = new ArrayList();<br />
<br />
			XmlNodeList xmlNodeList1 = XmlDocument1.GetElementsByTagName(elementName);<br />
<br />
			for (int idx = 0; idx < xmlNodeList1.Count; idx++) <br />
			{<br />
				XmlElement xmlElement1 = (XmlElement) xmlNodeList1[idx];<br />
				arrayList1.Add(xmlElement1.InnerText);<br />
			}<br />
	<br />
			return arrayList1;<br />
		}<br />
         }<br />
}<br />

//abcTabArea.cs
<br />
using System;<br />
using System.Collections;<br />
using System.ComponentModel;<br />
using System.Data;<br />
using System.Drawing;<br />
using System.Windows.Forms;<br />
<br />
namespace ABC.Components<br />
{<br />
	public class abcTabArea : System.Windows.Forms.UserControl<br />
	{<br />
		internal TabControl TabControl1;<br />
		internal string Path = "";<br />
<br />
<br />
		private System.ComponentModel.Container components = null;<br />
<br />
		public jmpBottom()<br />
		{<br />
			abcTabArea();<br />
		}<br />
<br />
		#region InitializeComponent()<br />
		private void InitializeComponent()<br />
		{<br />
			...<br />
		}<br />
		#endregion<br />
<br />
		public void CreateTabs(ArrayList arrayListTabNames1, string path)<br />
		{<br />
			this.Path = path;<br />
			for (int idx = 0; idx < arrayListTabNames1.Count; idx++)<br />
			{<br />
				string tab = "";<br />
				tab = arrayListTabNames1[idx].ToString();<br />
<br />
				System.Windows.Forms.TabPage abcTabPage = new TabPage(tab);<br />
<br />
				abcPage abcPage = new abcPage(tab,this.Path,idx);<br />
<br />
				this.abcTabControl1.Controls.Add(abcTabPage);<br />
				abcTabPage.Controls.Add(abcPage);<br />
<br />
			}<br />
		}<br />
<br />
<br />
		protected override void Dispose( bool disposing )<br />
		{<br />
			...<br />
		}<br />
<br />
	}<br />
}<br />

\\abcPage.cs
<br />
using System;<br />
using System.Collections;<br />
using System.ComponentModel;<br />
using System.Data;<br />
using System.Drawing;<br />
using System.Windows.Forms;<br />
using System.Xml;<br />
<br />
<br />
namespace ABC.Components<br />
{<br />
<br />
	public class abcPage : System.Windows.Forms.UserControl<br />
	{<br />
		internal string NodeName = "";<br />
		internal string Path = "";<br />
		internal int indexNum = 0;<br />
		private System.Windows.Forms.Panel panel1;<br />
		private System.Windows.Forms.DataGrid dataGrid1;<br />
		private System.ComponentModel.Container components = null;<br />
<br />
		public jmpPage(string nodeName, string path, int indexNum)<br />
		{<br />
			this.NodeName = nodeName;<br />
			this.Path = path;<br />
			this.indexNum = indexNum;<br />
			InitializeComponent();<br />
            		Populate();<br />
		}<br />
<br />
		#region InitializeComponent()<br />
<br />
		private void InitializeComponent()<br />
		{<br />
			this.panel1 = new System.Windows.Forms.Panel();<br />
			this.dataGrid1 = new System.Windows.Forms.DataGrid();<br />
			this.panel1.SuspendLayout();<br />
			((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).BeginInit();<br />
			this.SuspendLayout();<br />
			// <br />
			// panel1<br />
			// <br />
			this.panel1.Controls.Add(this.dataGrid1);<br />
			this.panel1.Location = new System.Drawing.Point(0, 0);<br />
			this.panel1.Name = "panel1";<br />
			this.panel1.Size = new System.Drawing.Size(800, 528);<br />
			this.panel1.TabIndex = 0;<br />
			// <br />
			// dataGrid1<br />
			// <br />
			this.dataGrid1.DataMember = "";<br />
			this.dataGrid1.HeaderForeColor = System.Drawing.SystemColors.ControlText;<br />
			this.dataGrid1.Location = new System.Drawing.Point(0, 0);<br />
			this.dataGrid1.Name = "dataGrid1";<br />
			this.dataGrid1.Size = new System.Drawing.Size(800, 528);<br />
			this.dataGrid1.TabIndex = 0;<br />
			// <br />
			// jmpGeneral<br />
			// <br />
			this.Controls.Add(this.panel1);<br />
			this.Size = new System.Drawing.Size(800, 528);<br />
			this.panel1.ResumeLayout(false);<br />
			((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).EndInit();<br />
			this.ResumeLayout(false);<br />
<br />
		}<br />
		#endregion<br />
<br />
		internal void Populate()<br />
		{<br />
			DataSet dataSet1 = new DataSet();<br />
			XmlDocument XmlDocument1;<br />
			XmlDocument1 = new XmlDocument();<br />
			XmlDocument1.PreserveWhitespace = false;<br />
			XmlDocument1.Load(this.Path);<br />
<br />
			XmlNodeList xmlNodeList = XmlDocument1.GetElementsByTagName("section");<br />
<br />
			XmlElement xmlElement1 = (XmlElement) xmlNodeList[this.indexNum];<br />
			dataSet1.ReadXml(this.Path);<br />
			dataGrid1.DataSource = dataSet1;<br />
			dataGrid1.DataMember = "section";<br />
			dataGrid1.CaptionText = dataGrid1.DataMember;<br />
		}<br />
<br />
		protected override void Dispose( bool disposing )<br />
		{<br />
			...<br />
		}<br />
	}<br />
}<br />

Question.NET windowsform XML editor control Pin
pmt1-Apr-06 0:45
pmt1-Apr-06 0:45 
QuestionVML Help??? Pin
Circleoaks30-Mar-06 7:12
Circleoaks30-Mar-06 7:12 
QuestionXML to datagrid WITHOUT FILE Pin
Centivi@29-Mar-06 12:20
Centivi@29-Mar-06 12:20 
AnswerRe: XML to datagrid WITHOUT FILE Pin
George L. Jackson29-Mar-06 17:31
George L. Jackson29-Mar-06 17:31 
GeneralRe: XML to datagrid WITHOUT FILE Pin
Centivi@30-Mar-06 1:48
Centivi@30-Mar-06 1:48 
QuestionAdd XML to an XMLNode Pin
NewbieDude28-Mar-06 1:23
NewbieDude28-Mar-06 1:23 
AnswerRe: Add XML to an XMLNode Pin
George L. Jackson29-Mar-06 17:36
George L. Jackson29-Mar-06 17:36 
GeneralRe: Add XML to an XMLNode Pin
NewbieDude29-Mar-06 19:46
NewbieDude29-Mar-06 19:46 
GeneralRe: Add XML to an XMLNode Pin
imsathy30-Mar-06 1:10
imsathy30-Mar-06 1:10 
QuestionUsing in XML Pin
Beringer27-Mar-06 8:09
Beringer27-Mar-06 8:09 
AnswerRe: Using in XML Pin
George L. Jackson28-Mar-06 10:35
George L. Jackson28-Mar-06 10:35 
AnswerRe: Using in XML Pin
DavidNohejl28-Mar-06 23:20
DavidNohejl28-Mar-06 23:20 
QuestionSchema and Stylesheet Pin
Chetan Ranpariya26-Mar-06 18:50
Chetan Ranpariya26-Mar-06 18:50 
AnswerRe: Schema and Stylesheet Pin
George L. Jackson27-Mar-06 11:33
George L. Jackson27-Mar-06 11:33 
GeneralRe: Schema and Stylesheet Pin
Chetan Ranpariya27-Mar-06 16:59
Chetan Ranpariya27-Mar-06 16:59 
GeneralRe: Schema and Stylesheet Pin
George L. Jackson28-Mar-06 10:27
George L. Jackson28-Mar-06 10:27 
QuestionJoin Query in XML Pin
Chetan Ranpariya26-Mar-06 17:40
Chetan Ranpariya26-Mar-06 17:40 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.