Adr Pan

Adr Pan

  • NA
  • 1
  • 2k

Need help with LINQ to XML in silverlight (instead of nodelist)

Nov 21 2011 4:54 PM
Hi!

I have this small xml file with the following content and a windowsform which is working fine.

<?xml version="1.0" encoding="utf-8" ?>
<start>
  <Q question="HW?">
    <Q question="PC?">
      <Q question="Client?">
        <A>http:\\www.dell.com</A>
      </Q>
      <Q question="Server?">
        <A>http:\\www.cisco.com</A>
      </Q>
    </Q>
    <Q question="MAC?"></Q>
  </Q>
  <Q question="SW?">
  </Q>
</start>

and a windowsform with this content

namespace WindowsFormsApplication12
{
    public partial class QuestionForm : Form
    {

        XmlNodeList nl;
        XmlNode nd1;
        XmlNode nd2;

        public QuestionForm(XmlNodeList nl)
        {
            InitializeComponent();

            this.nl = nl;

            Ask();

        }

        private void Ask()
        {            
            nd1 = nl[0];
            string question1 = nd1.Attributes["question"].Value;
            button1.Text = question1;

            nd2 = nl[1];
            string question2 = nd2.Attributes["question"].Value;
            button2.Text = question2;    
        }

        private void button1_Click(object sender, EventArgs e)
        {
            nl = nd1.ChildNodes;
            Ask();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            nl = nd2.ChildNodes;
            Ask();
        }
    }
}


My question is how can I get the same result in my Windows Phone application?
I guess it would work with LINQ but I couldnt make it.
Please help!