Click here to Skip to main content
15,929,795 members
Home / Discussions / C#
   

C#

 
GeneralRe: StackOverflow on OnComponentChanged Pin
sanicra13-May-07 14:31
sanicra13-May-07 14:31 
AnswerRe: StackOverflow on OnComponentChanged Pin
Luc Pattyn13-May-07 15:34
sitebuilderLuc Pattyn13-May-07 15:34 
GeneralRe: StackOverflow on OnComponentChanged Pin
sanicra13-May-07 15:46
sanicra13-May-07 15:46 
GeneralRe: StackOverflow on OnComponentChanged Pin
Luc Pattyn13-May-07 22:56
sitebuilderLuc Pattyn13-May-07 22:56 
GeneralRe: StackOverflow on OnComponentChanged Pin
sanicra13-May-07 23:18
sanicra13-May-07 23:18 
QuestionNeed Help With Console app (if CurAns > NoAns) Pin
emcp0613-May-07 9:35
emcp0613-May-07 9:35 
AnswerRe: Need Help With Console app (if CurAns > NoAns) Pin
Christian Graus13-May-07 11:50
protectorChristian Graus13-May-07 11:50 
QuestionQuestion about XML XPath Pin
Latheesan13-May-07 8:58
Latheesan13-May-07 8:58 
Hello,

I have a xml document like this:

< ? xml version = " 1.0 " ? >
< Accounts >
< Account ID = " 123456 " >
< FirstName > Latheesan < / FirstName >
< SecondName > Kanes < / SecondName >
< Balance > 0 < / Balance >
< OverDraftLimit > 50 < / OverDraftLimit >
< FullAddress > My Address Here < / FullAddress >
< / Account >
< / Accounts >

What i am trying to do is select one matching document node based on my XPath expression and then when found, assign each element node's value to set of strings.

So far, this is what i was able to do:

private void searchBtn1_Click(object sender, EventArgs e)<br />
        {<br />
            try<br />
            {<br />
                string fileName = "Account_Data.xml";<br />
                XPathDocument doc = new XPathDocument(fileName);<br />
                XPathNavigator nav = doc.CreateNavigator();<br />
<br />
                // Compile Standard XPath Expression<br />
                XPathExpression expr;<br />
                expr = nav.Compile("//Account[@ID='" + accountIDInput.Text + "']");<br />
                XPathNodeIterator iterator = nav.Select(expr);<br />
<br />
                // Results<br />
                nav.MoveToFirstChild();<br />
                MessageBox.Show(nav.Value);<br />
            }<br />
            catch (Exception ex)<br />
            {<br />
                MessageBox.Show("Error : " + ex.Message);<br />
            }<br />
        }


I printed the XPath Expression result using MessageBox.Show to see what the results would be like. On the message box, i saw the entire document node and it's element nodes and their values.

How do you obtain the results after running XPath expression and assign element node's value like this:

string AccountID = nav.value;
string FirstName = nav.value;
string SecondName = nav.value;
string Balance = nav.value;
string OverDraftLimit = nav.value;
string FullAddress = nav.value;
AnswerRe: Question about XML XPath Pin
Latheesan13-May-07 9:46
Latheesan13-May-07 9:46 
Questionrichtextbox newbie question Pin
RIPOUX13-May-07 7:48
RIPOUX13-May-07 7:48 
AnswerRe: richtextbox newbie question Pin
Latheesan13-May-07 9:03
Latheesan13-May-07 9:03 
GeneralRe: richtextbox newbie question Pin
RIPOUX13-May-07 9:30
RIPOUX13-May-07 9:30 
Questionsimple override and virtual question Pin
donovan.solms13-May-07 7:41
donovan.solms13-May-07 7:41 
AnswerRe: simple override and virtual question Pin
Luc Pattyn13-May-07 11:08
sitebuilderLuc Pattyn13-May-07 11:08 
GeneralRe: simple override and virtual question Pin
donovan.solms13-May-07 13:24
donovan.solms13-May-07 13:24 
QuestionDelegates and Threading Question Pin
C.Sharp.Mage13-May-07 7:29
C.Sharp.Mage13-May-07 7:29 
AnswerRe: Delegates and Threading Question Pin
Christian Graus13-May-07 12:03
protectorChristian Graus13-May-07 12:03 
GeneralRe: Delegates and Threading Question Pin
C.Sharp.Mage13-May-07 13:29
C.Sharp.Mage13-May-07 13:29 
QuestionSQLServer Express Edition Pin
Agyeman13-May-07 7:28
Agyeman13-May-07 7:28 
AnswerRe: SQLServer Express Edition Pin
RIPOUX13-May-07 7:55
RIPOUX13-May-07 7:55 
GeneralRe: SQLServer Express Edition Pin
Agyeman13-May-07 9:21
Agyeman13-May-07 9:21 
GeneralRe: SQLServer Express Edition Pin
Agyeman13-May-07 9:24
Agyeman13-May-07 9:24 
AnswerRe: SQLServer Express Edition Pin
Giorgi Dalakishvili13-May-07 7:55
mentorGiorgi Dalakishvili13-May-07 7:55 
GeneralRe: SQLServer Express Edition Pin
Agyeman13-May-07 9:25
Agyeman13-May-07 9:25 
QuestionUsing a C++ Static Library in C# code?? Pin
_Tom_13-May-07 6:40
_Tom_13-May-07 6: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.