Navigating with webbrowser using a string

369 views Asked by At

I was wondering if anyone would know why I can't call upon one of the strings below to use on a webBrowser.

    public void XMLR()
    {
        XmlDocument doc = new XmlDocument();
        Form1 frontmain = new Form1();
        doc.Load("C:\\myXmFile.xml");

        XmlNodeList bookList = doc.GetElementsByTagName("buttons");

        foreach (XmlNode node in bookList)
        {
            XmlElement bookElement = (XmlElement)node;

            string workshop1 = bookElement.GetElementsByTagName("workshop1")[0].InnerText;
            string workshop2 = bookElement.GetElementsByTagName("workshop2")[0].InnerText;
            string workshop3 = bookElement.GetElementsByTagName("workshop3")[0].InnerText;

    public void button1_Click(object sender, EventArgs e)
    {
        webBrowser1.Navigate(workshop1);
    }

It won't allow me to navigate using the string "workshop1" I am probably missing something or having a mental block-out. Thanks.

1

There are 1 answers

1
izb On BEST ANSWER

The variable is local to your constructor. Try declaring it at the class level

class XMLR
{
    private string workshop1;

    ...
}