Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# XML
I have xml code.
<?xml version="1.0" encoding="utf-8"?>
<Dictionary>
  <item>
    <key>
      <string>Question1:</string>
    </key>
    <value>
      <ArrayOfString xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
        <string>Answer1.</string>
        <string>Answer2.</string>
        <string>Answer3 </string>
      </ArrayOfString>
    </value>
  </item>
  <item>
    <key>
      <string>Question2:</string>
    </key>
    <value>
      <ArrayOfString xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
        <string>Answer3.</string>
        <string>Answer4</string>
        <string>Answer5</string>
      </ArrayOfString>
    </value>
  </item>
 
On form i have 4 elements (textbox's) . One - to question, and 3 to answes.
 
When i click on button program show me Question1 and hers answers. Clicking again- Question2 and hers answers.
 
doc = new XPathDocument(FILE_NAME);
            nav = doc.CreateNavigator();
 
         
            expr = nav.Compile("/Dictionary/item");
           
            iterator = nav.Select(expr);
            
            while (iterator.MoveNext())
                {
                    XPathNavigator nav2 = iterator.Current.Clone();
                    nav2.SelectChildren("string", "");
                    textBox1.Text = nav2.TypedValue.ToString(); 
                 }
 
I try it. This xml not have attributes. What i need doing?
Posted 6-Sep-12 1:59am
Radzhab1.2K
Comments
LAKHANP22 at 14-Sep-12 15:37pm
   
not clear ....please explain what u want to do

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



Advertise | Privacy | Mobile
Web02 | 2.8.141022.1 | Last Updated 6 Sep 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100