Click here to Skip to main content
15,944,733 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
ListBox listBox1 = new ListBox();
      1      string fileName = (Server.MapPath("OrgList.xml"));
      2      XPathDocument doc = new XPathDocument(fileName);
      3     XPathNavigator nav = doc.CreateNavigator();
            // Compile a standard XPath expression
      4     XPathExpression expr;
      5      expr = nav.Compile("//DATA_RECORD");
      6     XPathNodeIterator iterator = nav.Select(expr);
            // Iterate on the node set
      7      listBox1.Items.Clear();
            try
            {
                while (iterator.MoveNext())
                {
      8             XPathNavigator nav2 = iterator.Current.Clone();
      9             listBox1.Items.Add(nav2.Value);
                                      
                    
                }
            }
            catch (Exception ex)
            {
                Response.Write(ex.ToString());
            }

In line number 8 XPathNavigator nav2 has a node called DATE_RECORD which has first Name, lastName and an ID as a concatenated string together. I need to access those atributes one by one separately right after the execution of line 8. what member of the XPathNavigator will do that?. I'm stuck on this for almost two days please help.

I just want help on this please I can't go to a diffrenet approach now because its too late for me to do it.
Posted
Updated 23-Sep-11 3:49am
v2

If I have read your issue correctly and the concatenated strings are held in
nav2.Value then you just need to do a split based on whatever concatenation value you have used

C#
char seperator = '_'; // whatever you use to indicate the concatenation
string[] items = nav2.Value.Split(seperator);

//you should then have the values stored in
items[0]
items[1]
items[2]
 
Share this answer
 
Hi
You can access attribute values through GetAttribute method right?
nav2.GetAttribute("FirstName", "URI")
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900