xml description node to label

Joined
May 10, 2011
Messages
5
Programming Experience
Beginner
Firstly, hope this is in the right section.

I have been all over the net, but cant seem to find how to get this to work,

I have a windows form with a label, and i want that label to be populated by the description node in the below xml document

Can anyone give me some direction/help please

VB.NET:
<Title>
  <LocalTitle>4.3.2.1</LocalTitle>
  <OriginalTitle>4.3.2.1.</OriginalTitle>
  <SortTitle>4.3.2.1</SortTitle>
  <Added>1/22/2011 8:58:48 AM</Added>
  <ProductionYear>2010</ProductionYear>
  <RunningTime>117</RunningTime>
  <IMDBrating>6.0</IMDBrating>
  <MPAARating>NR</MPAARating>
  <Description>While Jo (Roberts) is chained down in a dead end supermarket job, her friends are all out on their own separate adventures: Cassandra (Egerton) is jetting off to New York to meet her Internet boyfriend; Kerrys (Warren-Markland) is on a one woman crusade fighting for female liberation and Shannon (Lovibond) is on a one way trip to meet her maker. But a chance encounter with some diamond thieves sends their separate worlds on a collision course with not only each other, but fate itself. These 4 girls are about to have 3 days they will never forget, spanning to 2 cities. That is ... if they survive.</Description>
  <Type>None</Type>
  <AspectRatio />
  <LockData>False</LockData>
  <IMDB>tt1514041</IMDB>
  <TMDbId>44877</TMDbId>
  <Genres>
    <Genre>Crime</Genre>
    <Genre>Thriller</Genre>
    <Genre>Action</Genre>
  </Genres>
  <Persons>
    <Person>
      <Name>Emma Roberts</Name>
      <Type>Actor</Type>
      <Role>Joanne</Role>
    </Person>
    <Person>
      <Name>Noel Clarke</Name>
      <Type>Actor</Type>
      <Role>Tee</Role>
    </Person>
    <Person>
      <Name>Ophelia Lovibond</Name>
      <Type>Actor</Type>
      <Role>Shannon</Role>
    </Person>
    <Person>
      <Name>Tamsin Egerton</Name>
      <Type>Actor</Type>
      <Role>Cassandra</Role>
    </Person>
    <Person>
      <Name>Shanika Warren-Markland</Name>
      <Type>Actor</Type>
      <Role>Kerrys</Role>
    </Person>
    <Person>
      <Name>Andrew Harwood Mills</Name>
      <Type>Actor</Type>
      <Role>Driving Instructor</Role>
    </Person>
    <Person>
      <Name>Ashley Bashy Thomas</Name>
      <Type>Actor</Type>
      <Role>Smoothy</Role>
    </Person>
    <Person>
      <Name>Ben Cooke</Name>
      <Type>Actor</Type>
      <Role>Big Thief</Role>
    </Person>
    <Person>
      <Name>Steven Cree</Name>
      <Type>Actor</Type>
      <Role>Scotty</Role>
    </Person>
    <Person>
      <Name>Michael Hunter</Name>
      <Type>Actor</Type>
      <Role>Tats - Dillon's Crew</Role>
    </Person>
    <Person>
      <Name>Sean Pertwee</Name>
      <Type>Actor</Type>
      <Role>Mr. Richards</Role>
    </Person>
    <Person>
      <Name>Alan McKenna</Name>
      <Type>Actor</Type>
      <Role>Mr. Jones</Role>
    </Person>
    <Person>
      <Name>Kate Magowan</Name>
      <Type>Actor</Type>
      <Role>Mrs. Richards</Role>
    </Person>
    <Person>
      <Name>Ben Shepherd</Name>
      <Type>Actor</Type>
      <Role>Newscaster</Role>
    </Person>
    <Person>
      <Name>Linzey Cocker</Name>
      <Type>Actor</Type>
      <Role>Gwen</Role>
    </Person>
    <Person>
      <Name>Adam Deacon</Name>
      <Type>Actor</Type>
      <Role>Dillon</Role>
    </Person>
    <Person>
      <Name>Gregg Chillin</Name>
      <Type>Actor</Type>
      <Role>Manuel</Role>
    </Person>
    <Person>
      <Name>Davie Fairbanks</Name>
      <Type>Actor</Type>
      <Role>Fraser</Role>
    </Person>
    <Person>
      <Name>Darcy Thomas</Name>
      <Type>Actor</Type>
      <Role>Youth At Canal</Role>
    </Person>
    <Person>
      <Name>Ermal Memia</Name>
      <Type>Actor</Type>
      <Role>Youth At Canal</Role>
    </Person>
    <Person>
      <Name>Michelle Ryan</Name>
      <Type>Actor</Type>
      <Role>Kelly</Role>
    </Person>
    <Person>
      <Name>Camille Coduri</Name>
      <Type>Actor</Type>
      <Role>Mrs. Phillips</Role>
    </Person>
    <Person>
      <Name>Ben Miller</Name>
      <Type>Actor</Type>
      <Role>Mr. Phillips</Role>
    </Person>
    <Person>
      <Name>Susannah Fielding</Name>
      <Type>Actor</Type>
      <Role>Jas</Role>
    </Person>
    <Person>
      <Name>Kevin Smith</Name>
      <Type>Actor</Type>
      <Role>Big Larry</Role>
    </Person>
    <Person>
      <Name>Laura Giddings</Name>
      <Type>Actor</Type>
      <Role>Virgin Atlantic Senior Cabin Crew</Role>
    </Person>
    <Person>
      <Name>Becky Giddings</Name>
      <Type>Actor</Type>
      <Role>Virgin Atlantic Senior Cabin Crew</Role>
    </Person>
    <Person>
      <Name>Freddie Stroma</Name>
      <Type>Actor</Type>
      <Role>Cool Brett</Role>
    </Person>
    <Person>
      <Name>Audrey Kaipio</Name>
      <Type>Actor</Type>
      <Role>Desk Clerk</Role>
    </Person>
    <Person>
      <Name>Adam Gillen</Name>
      <Type>Actor</Type>
      <Role>Geek Brett</Role>
    </Person>
    <Person>
      <Name>Natalie Britton</Name>
      <Type>Actor</Type>
      <Role>News Reporter Susan Sanders</Role>
    </Person>
    <Person>
      <Name>Mandy Patinkin</Name>
      <Type>Actor</Type>
      <Role>Sir Jago Larofsky</Role>
    </Person>
    <Person>
      <Name>Eve</Name>
      <Type>Actor</Type>
      <Role>Latisha</Role>
    </Person>
    <Person>
      <Name>Alexander Siddig</Name>
      <Type>Actor</Type>
      <Role>Mr. Jauo-Pinto</Role>
    </Person>
    <Person>
      <Name>Jay Read</Name>
      <Type>Actor</Type>
      <Role>Mrs. Jauo-Pinto</Role>
    </Person>
    <Person>
      <Name>Maria Consuelo S. Radclyffe</Name>
      <Type>Actor</Type>
      <Role>Grandmother</Role>
    </Person>
    <Person>
      <Name>Lourenco De Melo Castro</Name>
      <Type>Actor</Type>
      <Role>Grandfather</Role>
    </Person>
    <Person>
      <Name>Arnold Oceng</Name>
      <Type>Actor</Type>
      <Role>Dark Chocolate</Role>
    </Person>
    <Person>
      <Name>Jade Moira Lawrence</Name>
      <Type>Actor</Type>
      <Role>Fraser's Girl (as Jade Moira)</Role>
    </Person>
    <Person>
      <Name>Jon Dover</Name>
      <Type>Actor</Type>
      <Role>Big Guy</Role>
    </Person>
    <Person>
      <Name>Femi Oyeniran</Name>
      <Type>Actor</Type>
      <Role>Fraser's Mate #1</Role>
    </Person>
    <Person>
      <Name>Tristram Newham</Name>
      <Type>Actor</Type>
      <Role>Fraser's Mate #2</Role>
    </Person>
    <Person>
      <Name>Jo Martin</Name>
      <Type>Actor</Type>
      <Role>Driving Examiner</Role>
    </Person>
    <Person>
      <Name>Rickie Haywood-Williams</Name>
      <Type>Actor</Type>
      <Role>Newscaster - MTV</Role>
    </Person>
    <Person>
      <Name>Helen McCrory</Name>
      <Type>Actor</Type>
      <Role>Mrs. Jones</Role>
    </Person>
    <Person>
      <Name>Monty Croft</Name>
      <Type>Actor</Type>
      <Role>Ron The Security Guard</Role>
    </Person>
    <Person>
      <Name>Jacob Anderson</Name>
      <Type>Actor</Type>
      <Role>Angelo</Role>
    </Person>
    <Person>
      <Name>Nicholas Briggs</Name>
      <Type>Actor</Type>
      <Role>Barry</Role>
    </Person>
    <Person>
      <Name>Ben Drew</Name>
      <Type>Actor</Type>
      <Role>Terry</Role>
    </Person>
    <Person>
      <Name>Laura Whitmore</Name>
      <Type>Actor</Type>
      <Role>Newscaster - MTV</Role>
    </Person>
    <Person>
      <Name>James Bravery</Name>
      <Type>Actor</Type>
      <Role>Dave</Role>
    </Person>
    <Person>
      <Name>Steven Harvey</Name>
      <Type>Actor</Type>
      <Role>Customer</Role>
    </Person>
    <Person>
      <Name>Grace Wainwright</Name>
      <Type>Actor</Type>
      <Role>Detective Lydia Devon</Role>
    </Person>
    <Person>
      <Name>Adam Sagar Smith</Name>
      <Type>Actor</Type>
      <Role>Detective Quentin Boon</Role>
    </Person>
    <Person>
      <Name>Bartosz Wozniak</Name>
      <Type>Actor</Type>
      <Role>Kelly's Men #1</Role>
    </Person>
    <Person>
      <Name>Imre Elekes</Name>
      <Type>Actor</Type>
      <Role>Kelly's Men #2</Role>
    </Person>
    <Person>
      <Name>Ian Seale</Name>
      <Type>Actor</Type>
      <Role>Anchorman Ted</Role>
    </Person>
    <Person>
      <Name>Geoff Carino</Name>
      <Type>Actor</Type>
      <Role>Sleeping Man On Plane (uncredited)</Role>
    </Person>
    <Person>
      <Name>Andrew Dawson</Name>
      <Type>Actor</Type>
      <Role>Airline Passenger #2 (uncredited)</Role>
    </Person>
    <Person>
      <Name>Rochelle De-Terville</Name>
      <Type>Actor</Type>
      <Role>Passer By (uncredited)</Role>
    </Person>
    <Person>
      <Name>Lee Donaghy</Name>
      <Type>Actor</Type>
      <Role>Met Policeman (uncredited)</Role>
    </Person>
    <Person>
      <Name>Joyia Fitch</Name>
      <Type>Actor</Type>
      <Role>Young Hostage Couple (uncredited)</Role>
    </Person>
    <Person>
      <Name>Lee Nicholas Harris</Name>
      <Type>Actor</Type>
      <Role>Police Officer (uncredited)</Role>
    </Person>
    <Person>
      <Name>Sarah Linda</Name>
      <Type>Actor</Type>
      <Role>Party Girl (uncredited)</Role>
    </Person>
    <Person>
      <Name>Les Loveday</Name>
      <Type>Actor</Type>
      <Role>Barman (uncredited)</Role>
    </Person>
    <Person>
      <Name>Shaun Lucas</Name>
      <Type>Actor</Type>
      <Role>Airline Passenger (uncredited)</Role>
    </Person>
    <Person>
      <Name>Chris Mansfield</Name>
      <Type>Actor</Type>
      <Role>Police Officer (uncredited)</Role>
    </Person>
    <Person>
      <Name>Patricia Mantuano</Name>
      <Type>Actor</Type>
      <Role>Brazian Aunt (uncredited)</Role>
    </Person>
    <Person>
      <Name>Jack Marsh</Name>
      <Type>Actor</Type>
      <Role>Big Issue Seller (uncredited)</Role>
    </Person>
    <Person>
      <Name>Craig Miller</Name>
      <Type>Actor</Type>
      <Role>Billy (uncredited)</Role>
    </Person>
    <Person>
      <Name>John Warman</Name>
      <Type>Actor</Type>
      <Role>Police Officer (uncredited)</Role>
    </Person>
    <Person>
      <Name>Christopher Whitlow</Name>
      <Type>Actor</Type>
      <Role>Carl (uncredited)</Role>
    </Person>
    <Person>
      <Name>Elisha Willett</Name>
      <Type>Actor</Type>
      <Role>Coffee Shop Customer (uncredited)</Role>
    </Person>
    <Person>
      <Name>Noel Clarke</Name>
      <Type>Director</Type>
      <Role />
    </Person>
  </Persons>
  <Studios>
    <Studio>Unstoppable Entertainment</Studio>
    <Studio>Retro-juice Productions</Studio>
    <Studio>Atlantic Swiss Productions</Studio>
    <Studio>Veneration Music</Studio>
  </Studios>
  <ForcedTitle />
  <IMDbId>tt1514041</IMDbId>
  <CDUniverseId />
  <Language>English</Language>
  <Country>UK</Country>
  <Budget>4600000</Budget>
  <Revenue>0</Revenue>
</Title>
 
With linq to xml?
VB.NET:
[COLOR=#000000][FONT=Consolas]
   
[/FONT][/COLOR][COLOR=#000000][FONT=Consolas]
     [COLOR=#0000FF]Private[/COLOR] [COLOR=#0000FF]Function[/COLOR] GetDescription() [COLOR=#0000FF]As[/COLOR] [COLOR=#0000FF]String[/COLOR]
        [COLOR=#0000FF]Dim[/COLOR] doc [COLOR=#0000FF]As[/COLOR] XElement = GetDocument()
        [COLOR=#0000FF]Return[/COLOR] doc.<Description>.Value
    [COLOR=#0000FF]End[/COLOR] [COLOR=#0000FF]Function[/COLOR]
 
    [COLOR=#0000FF]Private[/COLOR] [COLOR=#0000FF]Function[/COLOR] GetDocument() [COLOR=#0000FF]As[/COLOR] XElement
        [COLOR=#008000]' reading the document from a file[/COLOR]
        [COLOR=#0000FF]Dim[/COLOR] result [COLOR=#0000FF]As[/COLOR] XElement = [COLOR=#0000FF]Nothing[/COLOR]
        Using reader [COLOR=#0000FF]As[/COLOR] [COLOR=#0000FF]New[/COLOR] XmlTextReader([COLOR=#006080]"myfile.xml"[/COLOR])
            result = XElement.Load(reader)
        [COLOR=#0000FF]End[/COLOR] Using
        [COLOR=#0000FF]Return[/COLOR] result
    [COLOR=#0000FF]End[/COLOR] [COLOR=#0000FF]Function[/COLOR][/FONT][/COLOR]
 
Last edited:
With linq to xml?
VB.NET:
[COLOR=#000000][FONT=Consolas]
   
[/FONT][/COLOR][COLOR=#000000][FONT=Consolas]
     [COLOR=#0000FF]Private[/COLOR] [COLOR=#0000FF]Function[/COLOR] GetDescription() [COLOR=#0000FF]As[/COLOR] [COLOR=#0000FF]String[/COLOR]
        [COLOR=#0000FF]Dim[/COLOR] doc [COLOR=#0000FF]As[/COLOR] XElement = GetDocument()
        [COLOR=#0000FF]Return[/COLOR] doc.<Description>.Value
    [COLOR=#0000FF]End[/COLOR] [COLOR=#0000FF]Function[/COLOR]
 
    [COLOR=#0000FF]Private[/COLOR] [COLOR=#0000FF]Function[/COLOR] GetDocument() [COLOR=#0000FF]As[/COLOR] XElement
        [COLOR=#008000]' reading the document from a file[/COLOR]
        [COLOR=#0000FF]Dim[/COLOR] result [COLOR=#0000FF]As[/COLOR] XElement = [COLOR=#0000FF]Nothing[/COLOR]
        Using reader [COLOR=#0000FF]As[/COLOR] [COLOR=#0000FF]New[/COLOR] XmlTextReader([COLOR=#006080]"myfile.xml"[/COLOR])
            result = XElement.Load(reader)
        [COLOR=#0000FF]End[/COLOR] Using
        [COLOR=#0000FF]Return[/COLOR] result
    [COLOR=#0000FF]End[/COLOR] [COLOR=#0000FF]Function[/COLOR][/FONT][/COLOR]

Thanks for the reply.

Im a bit of a coding n00b, so excuse my ignorance, but,

1.) what do you mean by With linq to xml?
2.) what part of the code display the <description> node text to the label ?

Thanks again,
 
1) LINQ to XML is just another way to build, write and read XML data in .NET.
Kind of like an easier API to work with XML.
It is what I use in the code I gave in my first post.

2) My code does not set the Text value of a label.
Supposing you would have a label named LabelDescription , it should work something like this:

LabelDescription.Text = GetDescription()
 
Me.LabelDescription.Text = XDocument.Load("file.xml")...<Description>.Value

A tip about the label for content like this, leave it at AutoSize and set the Width part of MaximumSize.
 
Back
Top