2

I have made something that reads from an xml file it all works perfectly. but there is one thing that wont work.

this is the xml part that works fine

<title>lorum ipsum lorum ipsum</title>

this is the xml part i want to read:

 <enclosure url="http://media.nu.nl/m/m1nxf1eaa6mh_sqr256.jpg" type="image/jpeg" />

i only want the url in a variable.

and this is what i have so far:

switch (node.Name)
                {
                    case "title": label5.Text = (node.InnerText); break;
                    case "enclosure": string picbox2 = (node.InnerText); break;
                        pictureBox2.ImageLocation = picbox2;
                    case "description": label6.Text = (node.InnerText); i++; break;

                }

i hope i have provided enough information.

Djeroen
  • 571
  • 6
  • 21

1 Answers1

2

Under the "enclosure" case, you have an assignment statement: pictureBox2.ImageLocation = picbox2; after the case's break; statement. I would not expect this to compile.

You also need to access element attributes as element.Attributes["attr_name"].Value rather than using the InnerText property which will bring back the text between the opening and closing element tags.

switch (node.Name)
{
    case "title": 
        label5.Text = (node.InnerText); 
        break;
    case "enclosure": 
        string picbox2 = (node.Attributes["url"].Value); 
        pictureBox2.ImageLocation = picbox2;
        break;
    case "description": 
        label6.Text = (node.InnerText); 
        i++; 
        break;

}
Rich
  • 3,781
  • 5
  • 34
  • 56