Click here to Skip to main content
15,902,299 members
Home / Discussions / C#
   

C#

 
AnswerRe: connection question Pin
Not Active3-Aug-06 7:33
mentorNot Active3-Aug-06 7:33 
Questionhi, [modified] Pin
Sunny H3-Aug-06 6:00
Sunny H3-Aug-06 6:00 
AnswerRe: hi, Pin
Ingo3-Aug-06 6:33
Ingo3-Aug-06 6:33 
QuestionHow can I run an executable from within my C# app Pin
sas94913-Aug-06 5:32
sas94913-Aug-06 5:32 
AnswerRe: How can I run an executable from within my C# app Pin
Not Active3-Aug-06 5:42
mentorNot Active3-Aug-06 5:42 
AnswerUse Rar Pin
Ennis Ray Lynch, Jr.3-Aug-06 5:45
Ennis Ray Lynch, Jr.3-Aug-06 5:45 
AnswerRe: How can I run an executable from within my C# app Pin
Dustin Metzgar3-Aug-06 5:54
Dustin Metzgar3-Aug-06 5:54 
QuestionXML Question [modified] Pin
SoftcodeSoftware3-Aug-06 5:18
SoftcodeSoftware3-Aug-06 5:18 
If I have an xml file such as below:

<printItAll>
<chatMessage>
<xml1>username</xml1>
<xml2>message here!</xml2>
<xml3>red</xml3>
<xml4>arial</xml4>
<msgID>3</msgID>
</chatMessage>
<chatMessage>
<xml1>Ben Griffiths</xml1>
<xml2>some random message</xml2>
<xml3>red</xml3>
<xml4>arial</xml4>
<msgID>4</msgID>
</chatMessage>
</printItAll>

How would I count the <chatMessage> elements, and how could I loop through them? At the moment my file only reads the first one. Here is my current code:

XmlDocument xDoc = new XmlDocument();
xDoc.Load("my_xml_file.xml");
XmlNodeList xml1 = xDoc.GetElementsByTagName("xml1");
XmlNodeList xml2 = xDoc.GetElementsByTagName("xml2");
XmlNodeList xml5 = xDoc.GetElementsByTagName("msgID");
string chat_memberU = (xml1[0].InnerText + ": ");
string chat_message = (xml2[0].InnerText);
int latestID = Int32.Parse(xml5[0].InnerText);

Many thanks, Ben.


-- modified at 11:19 Thursday 3rd August, 2006
AnswerRe: XML Question Pin
Stefan Troschuetz3-Aug-06 5:28
Stefan Troschuetz3-Aug-06 5:28 
AnswerRe: XML Question Pin
SoftcodeSoftware3-Aug-06 5:38
SoftcodeSoftware3-Aug-06 5:38 
Questioninterupting the loop with the button [modified] Pin
Blubbo3-Aug-06 5:00
Blubbo3-Aug-06 5:00 
AnswerRe: interupting the loop with the button Pin
User 66583-Aug-06 5:09
User 66583-Aug-06 5:09 
AnswerRe: interupting the loop with the button Pin
Not Active3-Aug-06 5:14
mentorNot Active3-Aug-06 5:14 
AnswerRe: interupting the loop with the button Pin
Stefan Troschuetz3-Aug-06 5:21
Stefan Troschuetz3-Aug-06 5:21 
GeneralRe: interupting the loop with the button Pin
Blubbo3-Aug-06 5:26
Blubbo3-Aug-06 5:26 
AnswerRe: interupting the loop with the button Pin
Nader Elshehabi3-Aug-06 5:31
Nader Elshehabi3-Aug-06 5:31 
QuestionAsynchronous socket question Pin
Madmaximus3-Aug-06 4:39
Madmaximus3-Aug-06 4:39 
AnswerRe: Asynchronous socket question Pin
Tim Kohler3-Aug-06 5:56
Tim Kohler3-Aug-06 5:56 
GeneralPrefix Pin
Ennis Ray Lynch, Jr.3-Aug-06 5:59
Ennis Ray Lynch, Jr.3-Aug-06 5:59 
AnswerRe: Asynchronous socket question Pin
RizwanSharp3-Aug-06 6:11
RizwanSharp3-Aug-06 6:11 
QuestionImpersonation + Process.Start Pin
Gonzalo Brusella3-Aug-06 4:12
Gonzalo Brusella3-Aug-06 4:12 
AnswerRe: Impersonation + Process.Start Pin
Judah Gabriel Himango3-Aug-06 6:25
sponsorJudah Gabriel Himango3-Aug-06 6:25 
GeneralRe: Impersonation + Process.Start Pin
Judah Gabriel Himango3-Aug-06 6:37
sponsorJudah Gabriel Himango3-Aug-06 6:37 
GeneralRe: Impersonation + Process.Start Pin
Gonzalo Brusella3-Aug-06 7:05
Gonzalo Brusella3-Aug-06 7:05 
QuestionCombobox problem Pin
ZeinaBaG3-Aug-06 3:37
ZeinaBaG3-Aug-06 3:37 

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.