Click here to Skip to main content
15,896,111 members
Home / Discussions / C#
   

C#

 
AnswerRe: How to check in form2 if a button on form1 has been clicked Pin
Paras Kaneriya12-Sep-07 22:32
Paras Kaneriya12-Sep-07 22:32 
Question[Message Deleted] Pin
P_Elza12-Sep-07 0:12
P_Elza12-Sep-07 0:12 
AnswerRe: Go to a particular node. Pin
Mark Churchill12-Sep-07 0:14
Mark Churchill12-Sep-07 0:14 
GeneralRe: Go to a particular node. Pin
P_Elza12-Sep-07 0:56
P_Elza12-Sep-07 0:56 
AnswerRe: Go to a particular node. Pin
Xmen Real 12-Sep-07 1:29
professional Xmen Real 12-Sep-07 1:29 
GeneralRe: Go to a particular node. Pin
P_Elza12-Sep-07 2:12
P_Elza12-Sep-07 2:12 
AnswerRe: Go to a particular node. Pin
Scott Dorman12-Sep-07 8:20
professionalScott Dorman12-Sep-07 8:20 
GeneralRe: Go to a particular node. [modified] Pin
P_Elza12-Sep-07 17:01
P_Elza12-Sep-07 17:01 
This is the xml
<?xml version="1.0" encoding="UTF-8" ?>
<family>
<name gender="male">
<firstname>Tom</firstname>
<lastname>Smith</lastname>
</name>
</family>

and the code is --------

FileStream fs = new FileStream("D:\\Myfolder\\gender.xml", FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
xmldoc.Load(fs);
XmlNodeList xmlnode = xmldoc.GetElementsByTagName("name");
for (int a = 0; a < xmlnode.Count; a++)
{
if (xmlnode[a].Attributes[0].Value == "gender")
// match your attributes
{ //codes
lblcnt.Text=a.ToString();
String firstNameValue = reader.ReadElementString("gender");
Lblmsg.Text=" FirstName: "+firstNameValue;
}
I tried this one also=======
XmlTextReader reader = new XmlTextReader ("D:\\Myfolder\\gender.xml");
XmlDocument xmldoc = new XmlDocument();
XmlTextReader reader = new XmlTextReader ("C:\\gender.xml");
try
{
while (!reader.EOF)
{
reader.Read();
if(reader.IsStartElement() )
{
reader.Read();
xmldoc.SelectSingleNode("family/name/firstname");
XmlNode xmlnode1=xmldoc.GetElementsByTagName("firstname");
String firstNameValue = reader.ReadElementString("firstname");
xmldoc.SelectSingleNode("lastname");
String lastNameValue = reader.ReadElementString("lastname");
Lblmsg.Text=" FirstName: "+firstNameValue + " LastName: " + lastNameValue;
}
}
reader.Close();
}
catch (Exception err )
{
Lblmsg.Text="Error: " + err.ToString();
}

Confused | :confused:


-- modified at 23:06 Wednesday 12th September, 2007
QuestionHash Table Pin
Nishad8512-Sep-07 0:07
Nishad8512-Sep-07 0:07 
AnswerRe: Hash Table Pin
mertkan6512-Sep-07 21:13
mertkan6512-Sep-07 21:13 
QuestionDraw gradient image Pin
greekius11-Sep-07 23:51
greekius11-Sep-07 23:51 
AnswerRe: Draw gradient image Pin
Amar Chaudhary12-Sep-07 0:33
Amar Chaudhary12-Sep-07 0:33 
QuestionProblem: tabControl (TabAlignment.Left) Pin
Soo Star11-Sep-07 23:39
Soo Star11-Sep-07 23:39 
AnswerRe: Problem: tabControl (TabAlignment.Left) Pin
Martin#12-Sep-07 8:35
Martin#12-Sep-07 8:35 
Questionequivalent of DocumentCompleted in WebBrowser while loading with AJAX Pin
scoroop11-Sep-07 23:37
scoroop11-Sep-07 23:37 
AnswerRe: equivalent of DocumentCompleted in WebBrowser while loading with AJAX Pin
scoroop12-Sep-07 3:15
scoroop12-Sep-07 3:15 
QuestionC# [DllImport()] questions. Pin
ioctl5111-Sep-07 23:34
ioctl5111-Sep-07 23:34 
AnswerRe: C# [DllImport()] questions. Pin
Malcolm Smart12-Sep-07 0:27
Malcolm Smart12-Sep-07 0:27 
AnswerRe: C# [DllImport()] questions. Pin
Luc Pattyn12-Sep-07 2:51
sitebuilderLuc Pattyn12-Sep-07 2:51 
Questiondata grid view Vs databinding Pin
iet200011-Sep-07 22:52
iet200011-Sep-07 22:52 
AnswerRe: data grid view Vs databinding Pin
Waleed Eissa11-Sep-07 23:12
Waleed Eissa11-Sep-07 23:12 
GeneralRe: data grid view Vs databinding Pin
iet200011-Sep-07 23:43
iet200011-Sep-07 23:43 
GeneralRe: data grid view Vs databinding Pin
Waleed Eissa11-Sep-07 23:58
Waleed Eissa11-Sep-07 23:58 
AnswerRe: data grid view Vs databinding Pin
Nouman Bhatti12-Sep-07 0:06
Nouman Bhatti12-Sep-07 0:06 
Questionnew namespaces?? Pin
Tarun.Suneja11-Sep-07 22:21
Tarun.Suneja11-Sep-07 22:21 

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.